Ignore:
Timestamp:
May 25, 2010 6:17:59 PM (14 years ago)
Author:
mylan
Message:

#250: Fixed and added test for reinstallation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py

    r2383 r2384  
    66from Products.CMFPlone.utils import _createObjectByType 
    77from Products.GenericSetup.upgrade import _upgrade_registry 
     8from quintagroup.plonegooglesitemaps import config 
     9from quintagroup.plonegooglesitemaps import upgrades as gsm_upgrades 
    810from quintagroup.canonicalpath.interfaces import ICanonicalPath 
    911from quintagroup.canonicalpath.interfaces import ICanonicalLink 
     
    4345        if step is not None: 
    4446            step.doStep(self.setup) 
    45         # canonical_path column must be added to portal_catalog 
     47        # Canonical_path column must be added to portal_catalog 
    4648        self.assertEqual("canonical_path" in catalog._catalog.names, True) 
    4749 
     
    6870        self.assertEqual(brain.canonical_link, migrated_link) 
    6971 
     72    def testUpgradeCallOnReinstall(self): 
     73        # Get upgrade steps 
     74        upgrades = _upgrade_registry.getUpgradeStepsForProfile(self.profile) 
     75        upgrades = dict([(u.sortkey, u) for u in upgrades.values()]) 
     76        try: 
     77            # Replace original handlers with patched ones for test calls 
     78            called = [] 
     79            upgrades[1].handler = lambda st:called.append("1.0 to 1.1") 
     80            upgrades[2].handler = lambda st:called.append("1.1 to 1.2") 
     81            # Run reinstallation 
     82            self.portal.portal_quickinstaller.reinstallProducts(products=config.PROJECTNAME) 
     83            # Test upgrades call 
     84            self.assertEqual("1.0 to 1.1" in called, True) 
     85            self.assertEqual("1.1 to 1.2" in called, True) 
     86        finally: 
     87            # Restore original upgrade handlers 
     88            upgrades[1].handler = gsm_upgrades.upgrade_1_0_to_1_1 
     89            upgrades[2].handler = gsm_upgrades.upgrade_1_1_to_1_2 
     90 
     91         
    7092 
    7193def test_suite(): 
     
    7799if __name__ == '__main__': 
    78100    unittest.main(defaultTest='test_suite') 
    79 #    framework() 
Note: See TracChangeset for help on using the changeset viewer.