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

Last change on this file since 3168 was 3168, checked in by vmaksymiv, 9 years ago

pep8, pyflakes fixes

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