Exemple #1
0
    def testMarkProductsInstalledForUninstallableProfiles(self):
        from plone.app.upgrade.v43.final import \
            markProductsInstalledForUninstallableProfiles

        qi = getToolByName(self.portal, 'portal_quickinstaller', None)
        if qi is None:
            # Newer Plone without qi.
            return

        # Register a profile.
        product_id = 'my.test.package'
        profile_id = '{0}:default'.format(product_id)
        profile_registry.registerProfile(
            'default', 'title', 'description', '/my/path',
            product=product_id, profile_type=EXTENSION)

        # Hide the profile.
        @implementer(INonInstallable)
        class HiddenProfiles(object):

            def getNonInstallableProfiles(self):
                return [profile_id]

        sm = getSiteManager()
        sm.registerUtility(factory=HiddenProfiles, name='my.test.package')

        # Check that nothing is installed at first.
        setup = getToolByName(self.portal, 'portal_setup')
        self.assertEqual(
            setup.getLastVersionForProfile(profile_id), 'unknown')
        self.assertFalse(qi.isProductInstalled(product_id))

        # Call our upgrade function.  This should have no effect,
        # because the profile is not installed.
        markProductsInstalledForUninstallableProfiles(setup)
        self.assertEqual(
            setup.getLastVersionForProfile(profile_id), 'unknown')
        self.assertFalse(qi.isProductInstalled(product_id))

        # Now fake that the profile is installed and try again.
        setup.setLastVersionForProfile(profile_id, '1.0')
        markProductsInstalledForUninstallableProfiles(setup)
        self.assertEqual(
            setup.getLastVersionForProfile(profile_id), ('1', '0'))
        self.assertTrue(qi.isProductInstalled(product_id))

        # Cleanup test.
        profile_registry.unregisterProfile('default', product_id)
Exemple #2
0
    def testMarkProductsInstalledForUninstallableProfiles(self):
        from plone.app.upgrade.v43.final import \
            markProductsInstalledForUninstallableProfiles

        qi = getToolByName(self.portal, 'portal_quickinstaller', None)
        if qi is None:
            # Newer Plone without qi.
            return

        # Register a profile.
        product_id = 'my.test.package'
        profile_id = '{0}:default'.format(product_id)
        profile_registry.registerProfile('default',
                                         'title',
                                         'description',
                                         '/my/path',
                                         product=product_id,
                                         profile_type=EXTENSION)

        # Hide the profile.
        @implementer(INonInstallable)
        class HiddenProfiles(object):
            def getNonInstallableProfiles(self):
                return [profile_id]

        sm = getSiteManager()
        sm.registerUtility(factory=HiddenProfiles, name='my.test.package')

        # Check that nothing is installed at first.
        setup = getToolByName(self.portal, 'portal_setup')
        self.assertEqual(setup.getLastVersionForProfile(profile_id), 'unknown')
        self.assertFalse(qi.isProductInstalled(product_id))

        # Call our upgrade function.  This should have no effect,
        # because the profile is not installed.
        markProductsInstalledForUninstallableProfiles(setup)
        self.assertEqual(setup.getLastVersionForProfile(profile_id), 'unknown')
        self.assertFalse(qi.isProductInstalled(product_id))

        # Now fake that the profile is installed and try again.
        setup.setLastVersionForProfile(profile_id, '1.0')
        markProductsInstalledForUninstallableProfiles(setup)
        self.assertEqual(setup.getLastVersionForProfile(profile_id),
                         ('1', '0'))
        self.assertTrue(qi.isProductInstalled(product_id))

        # Cleanup test.
        profile_registry.unregisterProfile('default', product_id)