Ignore:
Timestamp:
Aug 10, 2010 2:43:54 PM (14 years ago)
Author:
mylan
Message:

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

Location:
quintagroup.pfg.captcha/branches/migration/quintagroup/pfg/captcha/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.pfg.captcha/branches/migration/quintagroup/pfg/captcha/tests/base.py

    r2732 r2734  
    77from Products.Five import fiveconfigure 
    88from Testing import ZopeTestCase as ztc 
    9 from Products.PloneTestCase.layer import onsetup 
    109 
    1110from Products.PloneTestCase.layer import PloneSite 
     11from Products.PloneTestCase import setup as ptc_setup 
    1212from Products.PloneTestCase import PloneTestCase as ptc 
    13 from Products.PloneTestCase import setup as ptc_setup 
    14  
    15 from Products.PloneTestCase.PloneTestCase import portal_owner 
    16 from Products.PloneTestCase.PloneTestCase import default_password 
    1713 
    1814PACKAGES = [ 
     
    2016    'quintagroup.pfg.captcha', 
    2117] 
    22 PROFILES = [p+':default' for p in PACKAGES] 
    2318REQUIREMENTS = ['PloneFormGen',] + PACKAGES 
    2419 
     
    3833        ztc.installPackage('quintagroup.captcha.core') 
    3934 
     35    @classmethod 
     36    def tearDown(cls): 
     37        ptc_setup.cleanupPloneSite(ptc_setup.portal_name) 
     38 
    4039 
    4140class Installed(NotInstalled): 
     
    5150        # Install PROJECT 
    5251        qi = getattr(portal, 'portal_quickinstaller', None) 
    53         for p in REQUIREMENTS: 
    54             qi.installProduct(p) 
     52        qi.installProduct("quintagroup.pfg.captcha") 
    5553        transaction.commit() 
    5654 
     
    6361    layer = Installed 
    6462 
     63 
    6564class TestCaseNotInstalled(ptc.PloneTestCase): 
    6665    layer = NotInstalled 
  • quintagroup.pfg.captcha/branches/migration/quintagroup/pfg/captcha/tests/testMigration.py

    r2732 r2734  
    55 
    66class TestMigration(TestCaseNotInstalled): 
     7    """Migration perform recreation old CaptchaField 
     8    objects from qPloneCaptchaField product to new 
     9    CaptchaField from quintagroup.pfg.captcha package. 
    710 
    8     def installPFGCaptcha(self): 
    9         for p in REQUIREMENTS: 
    10             self.addProduct(p) 
     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    """ 
    1126 
    1227    def afterSetUp(self): 
    1328        self.loginAsPortalOwner() 
     29        self.qi = self.portal.portal_quickinstaller 
     30        self.pt = self.portal.portal_types 
     31        self.prepareToMigration() 
    1432 
    15     def test1(self): 
    16         qi = self.portal.portal_quickinstaller 
    17         import pdb;pdb.set_trace() 
    18         self.assert_(not qi.isProductInstalled("quintagroup.pfg.captcha")) 
    19         self.installPFGCaptcha() 
    20         self.assert_(qi.isProductInstalled("quintagroup.pfg.captcha")) 
     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) 
    2153 
    2254 
Note: See TracChangeset for help on using the changeset viewer.