示例#1
0
    def test_upgrade_all(self):
        from Products.CMFPlone.MigrationTool import Addon
        from Products.CMFPlone.MigrationTool import AddonList
        # real ones:
        cmfeditions = Addon(profile_id=u'Products.CMFEditions:CMFEditions')
        discussion = Addon(profile_id=u'plone.app.discussion:default')
        # real one with failing check_module:
        dexterity = Addon(profile_id=u'plone.app.dexterity:default',
                          check_module='no.such.module')
        # non-existing one:
        foo = Addon(profile_id='foo')
        addonlist = AddonList([
            cmfeditions,
            discussion,
            dexterity,
            foo
            ])
        # Calling it should give no errors.
        addonlist.upgrade_all(self.portal)

        # Get the last CMFEditions profile version, as that will be
        # the only one that gets upgraded during the second upgrade.
        setup = getToolByName(self.portal, "portal_setup")
        cmfeditions_version = setup.getLastVersionForProfile(
            cmfeditions.profile_id)

        # Now mess with the profile versions.
        setup.setLastVersionForProfile(cmfeditions.profile_id, '2.0')
        setup.setLastVersionForProfile(dexterity.profile_id, '0.1')
        # 'unknown' needs special handling, otherwise the version will
        # become a tuple ('unknown',):
        setup._profile_upgrade_versions[discussion.profile_id] = 'unknown'

        # Run the upgrade again.
        addonlist.upgrade_all(self.portal)

        # Check the profile versions.
        # CMFEditions should be the last one:
        self.assertEqual(
            setup.getLastVersionForProfile(cmfeditions.profile_id),
            cmfeditions_version)
        # We had set discussion to unknown, so it will not have been
        # upgraded:
        self.assertEqual(
            setup.getLastVersionForProfile(discussion.profile_id),
            'unknown')
        # We had given dexterity a failing check_module, so it will
        # not have been upgraded:
        self.assertEqual(
            setup.getLastVersionForProfile(dexterity.profile_id),
            ('0', '1'))
        # The foo profile never existed:
        self.assertEqual(
            setup.getLastVersionForProfile(foo.profile_id),
            'unknown')
示例#2
0
 def test_addon_safe(self):
     from Products.CMFPlone.MigrationTool import Addon
     addon = Addon(profile_id=_DEFAULT_PROFILE)
     self.assertTrue(addon.safe())
     addon = Addon(profile_id=_DEFAULT_PROFILE,
                   check_module='Products.CMFPlone')
     self.assertTrue(addon.safe())
     addon = Addon(profile_id=_DEFAULT_PROFILE,
                   check_module='Products.CMFPlone.foobarbaz')
     self.assertFalse(addon.safe())
示例#3
0
    def test_addon_safe(self):
        from Products.CMFPlone.MigrationTool import Addon

        addon = Addon(profile_id=_DEFAULT_PROFILE)
        self.assertTrue(addon.safe())
        addon = Addon(profile_id=_DEFAULT_PROFILE, check_module="Products.CMFPlone")
        self.assertTrue(addon.safe())
        addon = Addon(profile_id=_DEFAULT_PROFILE, check_module="Products.CMFPlone.foobarbaz")
        self.assertFalse(addon.safe())
示例#4
0
 def test_addon_repr(self):
     from Products.CMFPlone.MigrationTool import Addon
     addon = Addon(profile_id='foo')
     self.assertEqual(repr(addon), u'<Addon profile foo>')
     self.assertEqual(str(addon), '<Addon profile foo>')