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

Last change on this file since 2737 was 2737, checked in by mylan, 14 years ago

Merged revisions 3750,3767-3774 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.pfg.captcha/branches/migration

........

r3750 | mylan | 2010-07-20 23:44:36 +0300 (Tue, 20 Jul 2010) | 1 line


#222: Added basic structure of migration Product to Package

........

r3767 | mylan | 2010-08-09 20:59:55 +0300 (Mon, 09 Aug 2010) | 1 line


Fix validator registration breakage

........

r3768 | mylan | 2010-08-09 21:07:08 +0300 (Mon, 09 Aug 2010) | 1 line


#222: Added migratioin old Products.qPloneCaptchaField to quintagroup.pfg.captcha fields

........

r3769 | mylan | 2010-08-10 12:19:58 +0300 (Tue, 10 Aug 2010) | 1 line


#222: Fix typo

........

r3770 | mylan | 2010-08-10 12:59:59 +0300 (Tue, 10 Aug 2010) | 1 line


#222: Move installation quintagroup.pfg.captcha with dependecies from global setupPloneSite to TestCase? classes

........

r3771 | mylan | 2010-08-10 14:09:48 +0300 (Tue, 10 Aug 2010) | 1 line


#222: Splited tests.py module into 2 layers with notinstalled and installed quintagroup.pfg.captcha packages

........

r3772 | mylan | 2010-08-10 17:43:03 +0300 (Tue, 10 Aug 2010) | 1 line


#222: Fix uninstallation 'old' packages when second run quintagroup.pfg.captcha installation

........

r3773 | mylan | 2010-08-10 17:43:54 +0300 (Tue, 10 Aug 2010) | 1 line


#222: Added test for migration from old qPloneCaptchaField to new quintagroup.pfg.captcha

........

r3774 | mylan | 2010-08-10 18:03:41 +0300 (Tue, 10 Aug 2010) | 1 line


#222: Prepare to 1.0.1 release

........

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1from base import *
2from Products.PloneTestCase.setup import cleanupPloneSite
3from Products.PloneTestCase.setup import portal_name
4from Products.PloneTestCase.setup import SiteCleanup
5
6class TestMigration(TestCaseNotInstalled):
7    """Migration perform recreation old CaptchaField
8    objects from qPloneCaptchaField product to new
9    CaptchaField from quintagroup.pfg.captcha package.
10
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.
15
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
27    def afterSetUp(self):
28        self.loginAsPortalOwner()
29        self.qi = self.portal.portal_quickinstaller
30        self.pt = self.portal.portal_types
31        self.prepareToMigration()
32
33    def beforeTearDown(self):
34        self.qi.uninstallProducts(["quintagroup.pfg.captcha",])
35
36    def prepareToMigration(self):
37        # Install types
38        self.addProduct("quintagroup.pfg.captcha")
39        # Add captcha field
40        self.portal.invokeFactory("FormFolder", 'test_form')
41        test_form = self.portal['test_form']
42        test_form.invokeFactory("CaptchaField", 'test_captcha_field')
43        self.cf_path = "test_form/key"
44        self.old_cf = self.portal.unrestrictedTraverse(self.cf_path) 
45        self.assert_(self.old_cf)
46        self.pt['CaptchaField'].manage_changeProperties(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.