def test_list_steps(self): portal = self.layer['portal'] setup = getToolByName(portal, "portal_setup") upgrades = ensure_no_upgrades(setup) for profile, steps in upgrades.items(): self.assertEquals(len(steps), 0, "Found unexpected upgrades: %s" % steps)
def test_upgrades(self): self.importFile(__file__, 'fourtysix.zexp') portal = getattr(self.layer['app'], self.site_id) # TODO - we should do this in a layer self.layer['portal'] = portal setSite(portal) self.portal = portal # Adjust for some things changed by the testing infrastructure portal.setTitle('intranett.no') portal.portal_migration.upgrade(swallow_errors=False) setup = getToolByName(portal, "portal_setup") config.run_all_upgrades(setup, skip_policy=True) # run the upgrade steps for the policy request = self.layer['request'] request['profile_id'] = config.policy_profile upgrades = setup.listUpgrades(config.policy_profile) for u in upgrades: dest = u['sdest'] before_name = "before_%s" % dest before = getattr(self, before_name, None) if before is not None: before() request.form['upgrades'] = [u['id']] setup.manage_doUpgrades(request=request) after_name = "after_%s" % dest after = getattr(self, after_name, None) self.assertFalse( after is None, "The %s class is missing the %s function to check the upgrade " "to version %s" % (self.__class__.__name__, after_name, dest)) after() # test the end result upgrades = ensure_no_upgrades(setup) for profile, steps in upgrades.items(): self.assertEquals(len(steps), 0, "Found unexpected upgrades: %s" % steps) login(self.layer['app'], SITE_OWNER_NAME) diff = self.export() remaining = self.parse_diff(diff) def _print(values): # pragma: no cover for v in values: pprint(v.split('\n')) self.assertEqual(set(remaining.keys()), set([]), _print(remaining.values()))
def test_upgrades(self): self.importFile(__file__, 'fourtysix.zexp') portal = getattr(self.layer['app'], self.site_id) # TODO - we should do this in a layer self.layer['portal'] = portal setSite(portal) self.portal = portal # Adjust for some things changed by the testing infrastructure portal.setTitle('intranett.no') portal.portal_migration.upgrade(swallow_errors=False) setup = getToolByName(portal, "portal_setup") config.run_all_upgrades(setup, skip_policy=True) # run the upgrade steps for the policy request = self.layer['request'] request['profile_id'] = config.policy_profile upgrades = setup.listUpgrades(config.policy_profile) for u in upgrades: dest = u['sdest'] before_name = "before_%s" % dest before = getattr(self, before_name, None) if before is not None: before() request.form['upgrades'] = [u['id']] setup.manage_doUpgrades(request=request) after_name = "after_%s" % dest after = getattr(self, after_name, None) self.assertFalse(after is None, "The %s class is missing the %s function to check the upgrade " "to version %s" % (self.__class__.__name__, after_name, dest)) after() # test the end result upgrades = ensure_no_upgrades(setup) for profile, steps in upgrades.items(): self.assertEquals(len(steps), 0, "Found unexpected upgrades: %s" % steps) login(self.layer['app'], SITE_OWNER_NAME) diff = self.export() remaining = self.parse_diff(diff) def _print(values): # pragma: no cover for v in values: pprint(v.split('\n')) self.assertEqual(set(remaining.keys()), set([]), _print(remaining.values()))