def test_execute_upgrades_explicitly_allowed_even_on_outdated_plone(
            self, browser):
        self.package.with_profile(
            Builder('genericsetup profile').with_upgrade(
                Builder('ftw upgrade step').to(datetime(
                    2011, 1, 1)).named('The first upgrade step')))

        with self.package_created():
            self.install_profile('the.package:default', version='1')
            self.clear_recorded_upgrades('the.package:default')
            portal_migration = get_portal_migration(self.layer['portal'])
            portal_migration.setInstanceVersion('1.0.0')
            transaction.commit()
            self.assertFalse(
                self.is_installed('the.package:default', datetime(2011, 1, 1)))

            self.api_request(
                'POST', 'execute_upgrades', {
                    'upgrades:list': '[email protected]:default',
                    'allow_outdated': True
                })
            self.assertTrue(
                self.is_installed('the.package:default', datetime(2011, 1, 1)))
            self.assertEqual(
                ['UPGRADE STEP the.package:default: The first upgrade step.'],
                re.findall(r'UPGRADE STEP.*', browser.contents))
            self.assertIn('Result: SUCCESS', browser.contents)
    def test_execute_upgrades_not_allowed_when_plone_outdated(self, browser):
        self.package.with_profile(
            Builder('genericsetup profile').with_upgrade(
                Builder('ftw upgrade step').to(datetime(
                    2011, 1, 1)).named('The first upgrade step')))

        with self.package_created():
            self.install_profile('the.package:default', version='1')
            self.clear_recorded_upgrades('the.package:default')
            portal_migration = get_portal_migration(self.layer['portal'])
            portal_migration.setInstanceVersion('1.0.0')
            transaction.commit()
            self.assertFalse(
                self.is_installed('the.package:default', datetime(2011, 1, 1)))

            with self.expect_api_error(
                    status=400,
                    message='Plone site outdated',
                    details='The Plone site is outdated and needs to'
                    ' be upgraded first using the regular Plone'
                    ' upgrading tools.'):
                self.api_request(
                    'POST', 'execute_upgrades',
                    {'upgrades:list': '[email protected]:default'})
            self.assertFalse(
                self.is_installed('the.package:default', datetime(2011, 1, 1)))
Beispiel #3
0
    def plone_upgrade(self):
        """Upgrade the Plone Site.

        This is what you would manually do in the @@plone-upgrade view.
        """
        portal_migration = get_portal_migration(self.context)
        if not portal_migration.needUpgrading():
            return 'Plone Site was already up to date.'
        portal_migration.upgrade(swallow_errors=False)
        return 'Plone Site has been updated.'
Beispiel #4
0
 def _require_up_to_date_plone_site(self):
     portal_migration = get_portal_migration(self.context)
     if portal_migration.needUpgrading():
         raise PloneSiteOutdated()
Beispiel #5
0
 def plone_upgrade_needed(self):
     """Returns "true" when Plone needs to be upgraded.
     """
     portal_migration = get_portal_migration(self.context)
     return bool(portal_migration.needUpgrading())
    def test_portal_migration_tool_is_wrapped_in_request_container(self):
        portal = self.layer['portal']
        portal_migration = get_portal_migration(portal)

        self.assertIsInstance(portal_migration.REQUEST, HTTPRequest)
        self.assertIsInstance(aq_chain(portal_migration)[-1], RequestContainer)
Beispiel #7
0
 def plone_needs_upgrading(self):
     portal_migration = get_portal_migration(self.context)
     return portal_migration.needUpgrading()