Changeset 2384 in products


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

#250: Fixed and added test for reinstallation

Location:
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/Extensions/Install.py

    r2376 r2384  
     1import logging 
    12from Products.CMFCore.utils import getToolByName 
    23from Products.GenericSetup.upgrade import _upgrade_registry 
    34 
     5logger = logging.getLogger("quintagroup.plonegooglesitemaps") 
    46PROFILE = "profile-quintagroup.plonegooglesitemaps:default" 
    57 
     
    1618        step = None 
    1719        profile_id = 'quintagroup.plonegooglesitemaps:default' 
    18         steps_to_run = [s['id'] for s in setup_tool.listUpgrades(profile_id, show_old=False)] 
     20        steps_to_run = [s['id'] for s in ps.listUpgrades(profile_id, show_old=False)] 
    1921        for step_id in steps_to_run: 
    2022            step = _upgrade_registry.getUpgradeStep(profile_id, step_id) 
    21             step.doStep(setup_tool) 
     23            step.doStep(ps) 
    2224            msg = "Ran upgrade step %s for profile %s" % (step.title, profile_id) 
    2325            logger.log(logging.INFO, msg) 
     
    2527        # with running an upgrade step. 
    2628        if step and step.dest is not None and step.checker is None: 
    27            setup_tool.setLastVersionForProfile(profile_id, step.dest) 
     29           ps.setLastVersionForProfile(profile_id, step.dest) 
    2830        return "Ran all reinstall steps." 
    2931 
  • 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.