source: products/quintagroup.pfg.captcha/trunk/quintagroup/pfg/captcha/tests/testMigration.py @ 3212

Last change on this file since 3212 was 3212, checked in by vmaksymiv, 13 years ago

fixed tests plone3.0 compatibility

  • Property svn:eol-style set to native
File size: 2.2 KB
RevLine 
[3168]1import unittest
[3212]2from quintagroup.pfg.captcha.tests.base import TestCaseNotInstalled, \
3    REQUIREMENTS
[2732]4
[3168]5
[2732]6class TestMigration(TestCaseNotInstalled):
[2734]7    """Migration perform recreation old CaptchaField
8    objects from qPloneCaptchaField product to new
9    CaptchaField from quintagroup.pfg.captcha package.
[2732]10
[2734]11    Migration based on:
12      * presence old portal type CaptchaField with
13        "qPloneCaptchaField" value in *product* field.
14      * presence of CaptchaField objects on the site.
[2732]15
[2734]16    This TestCase emulate migration with:
17      1. Install new quintagroup.pfg.captcha package
18         and add test CaptchaField object.
19      2. Change *product" field value in
20         portal_tyeps/CaptchaField FTI
21    Then it install quintagroup.pfg.captcha and test if
22    tested CaptchaField object is recreated and *product*
23    field for portal_type/CaptchaField is changed to
24    quintagroup.pfg.captcha.
25    """
26
[2732]27    def afterSetUp(self):
28        self.loginAsPortalOwner()
[2734]29        self.qi = self.portal.portal_quickinstaller
30        self.pt = self.portal.portal_types
31        self.prepareToMigration()
[2732]32
[2734]33    def beforeTearDown(self):
[3168]34        self.qi.uninstallProducts(["quintagroup.pfg.captcha", ])
[2732]35
[2734]36    def prepareToMigration(self):
37        # Install types
[3212]38        for p in REQUIREMENTS:
39            if not self.qi.isProductInstalled(p):
40                self.qi.installProduct(p)
[2734]41        # Add captcha field
42        self.portal.invokeFactory("FormFolder", 'test_form')
43        test_form = self.portal['test_form']
44        test_form.invokeFactory("CaptchaField", 'test_captcha_field')
45        self.cf_path = "test_form/key"
[3168]46        self.old_cf = self.portal.unrestrictedTraverse(self.cf_path)
[2734]47        self.assert_(self.old_cf)
[3168]48        self.pt['CaptchaField'].manage_changeProperties(
49            product="qPloneCaptchaField")
[2734]50        self.qi.manage_delObjects('quintagroup.pfg.captcha')
[2732]51
[2734]52    def testMigration(self):
53        self.addProduct("quintagroup.pfg.captcha")
[3168]54        new_cf = self.portal.unrestrictedTraverse(self.cf_path)
[2734]55        self.assert_(self.old_cf != new_cf)
56
57
[2732]58def test_suite():
59    suite = unittest.TestSuite()
60    suite.addTest(unittest.makeSuite(TestMigration))
61    return suite
Note: See TracBrowser for help on using the repository browser.