[3168] | 1 | import unittest |
---|
| 2 | from quintagroup.pfg.captcha.tests.base import TestCaseNotInstalled |
---|
[2732] | 3 | |
---|
[3168] | 4 | |
---|
[2732] | 5 | class TestMigration(TestCaseNotInstalled): |
---|
[2734] | 6 | """Migration perform recreation old CaptchaField |
---|
| 7 | objects from qPloneCaptchaField product to new |
---|
| 8 | CaptchaField from quintagroup.pfg.captcha package. |
---|
[2732] | 9 | |
---|
[2734] | 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. |
---|
[2732] | 14 | |
---|
[2734] | 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 | |
---|
[2732] | 26 | def afterSetUp(self): |
---|
| 27 | self.loginAsPortalOwner() |
---|
[2734] | 28 | self.qi = self.portal.portal_quickinstaller |
---|
| 29 | self.pt = self.portal.portal_types |
---|
| 30 | self.prepareToMigration() |
---|
[2732] | 31 | |
---|
[2734] | 32 | def beforeTearDown(self): |
---|
[3168] | 33 | self.qi.uninstallProducts(["quintagroup.pfg.captcha", ]) |
---|
[2732] | 34 | |
---|
[2734] | 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" |
---|
[3168] | 43 | self.old_cf = self.portal.unrestrictedTraverse(self.cf_path) |
---|
[2734] | 44 | self.assert_(self.old_cf) |
---|
[3168] | 45 | self.pt['CaptchaField'].manage_changeProperties( |
---|
| 46 | product="qPloneCaptchaField") |
---|
[2734] | 47 | self.qi.manage_delObjects('quintagroup.pfg.captcha') |
---|
[2732] | 48 | |
---|
[2734] | 49 | def testMigration(self): |
---|
| 50 | self.addProduct("quintagroup.pfg.captcha") |
---|
[3168] | 51 | new_cf = self.portal.unrestrictedTraverse(self.cf_path) |
---|
[2734] | 52 | self.assert_(self.old_cf != new_cf) |
---|
| 53 | |
---|
| 54 | |
---|
[2732] | 55 | def test_suite(): |
---|
| 56 | suite = unittest.TestSuite() |
---|
| 57 | suite.addTest(unittest.makeSuite(TestMigration)) |
---|
| 58 | return suite |
---|