예제 #1
0
    def tearDownPloneSite(self, portal):
        QuickInstallerTool.isProductInstallable = TEST_PATCHES['orig_isProductInstallable']

        profile_registry.unregisterProfile('test', 'Products.CMFQuickInstallerTool')

        sm = zope.component.getSiteManager()
        sm.unregisterHandler(handleBeforeProfileImportEvent)
        sm.unregisterHandler(handleProfileImportedEvent)
 def tearDownZope(self, app):
     profile_registry.unregisterProfile(
         'default',
         'Products.CMFQuickInstallerTool.tests'
     )
     sm = zope.component.getSiteManager()
     sm.unregisterHandler(handleBeforeProfileImportEvent)
     sm.unregisterHandler(handleProfileImportedEvent)
예제 #3
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)
예제 #4
0
    def test_no_longer_existing_profiles_are_silently_removed(self):
        self.package.with_profile(Builder('genericsetup profile')
                                  .with_upgrade(self.default_upgrade())
                                  .with_dependencies('the.package:removed'))

        self.package.with_profile(Builder('genericsetup profile')
                                  .named('removed')
                                  .with_upgrade(self.default_upgrade()))

        with self.package_created():
            self.install_profile('the.package:default')
            self.assertEquals(['the.package:removed', 'the.package:default'],
                              self.get_listed_profiles())

            from Products.GenericSetup import profile_registry
            profile_registry.unregisterProfile('removed', 'the.package')

            self.assertEquals(['the.package:default'],
                              self.get_listed_profiles())
예제 #5
0
파일: tests.py 프로젝트: CGTIC/Plone_SP
 def testCleanupUninstalledProducts(self):
     from plone.app.upgrade.v43.final import cleanupUninstalledProducts
     qi = getToolByName(self.portal, 'portal_quickinstaller')
     setup = getToolByName(self.portal, 'portal_setup')
     # Register three profiles.  I wanted to take 'new' as product
     # id, but there is already a python module 'new', so that goes
     # wrong.
     profile_registry.registerProfile(
         'default', '', '', '/my/path',
         product='newproduct', profile_type=EXTENSION)
     profile_registry.registerProfile(
         'default', '', '', '/my/path',
         product='installed', profile_type=EXTENSION)
     profile_registry.registerProfile(
         'default', '', '', '/my/path',
         product='uninstalled', profile_type=EXTENSION)
     # Mark as installed.
     setup.setLastVersionForProfile('newproduct:default', '1')
     setup.setLastVersionForProfile('installed:default', '1')
     setup.setLastVersionForProfile('uninstalled:default', '1')
     # Notify of installation of three products.
     qi.notifyInstalled('newproduct', status='new')
     qi.notifyInstalled('installed', status='installed')
     qi.notifyInstalled('uninstalled', status='uninstalled')
     # The status differs, so QI does not think all are actually
     # installed.
     self.assertFalse(qi.isProductInstalled('newproduct'))
     self.assertTrue(qi.isProductInstalled('installed'))
     self.assertFalse(qi.isProductInstalled('uninstalled'))
     # But all three have an object in the QI.
     self.assertTrue('newproduct' in qi)
     self.assertTrue('installed' in qi)
     self.assertTrue('uninstalled' in qi)
     # And all three have a version in GS.
     self.assertEqual(
         setup.getLastVersionForProfile('newproduct:default'), ('1',))
     self.assertEqual(
         setup.getLastVersionForProfile('installed:default'), ('1',))
     self.assertEqual(
         setup.getLastVersionForProfile('uninstalled:default'), ('1',))
     # Call our cleanup function.
     cleanupUninstalledProducts(setup)
     # Same results for isProductInstalled.
     self.assertFalse(qi.isProductInstalled('newproduct'))
     self.assertTrue(qi.isProductInstalled('installed'))
     self.assertFalse(qi.isProductInstalled('uninstalled'))
     # The two not installed items are removed.
     self.assertFalse('newproduct' in qi)
     self.assertTrue('installed' in qi)
     self.assertFalse('uninstalled' in qi)
     # Those twee are unknown in GS.
     self.assertEqual(
         setup.getLastVersionForProfile('newproduct:default'), 'unknown')
     self.assertEqual(
         setup.getLastVersionForProfile('installed:default'), ('1',))
     self.assertEqual(
         setup.getLastVersionForProfile('uninstalled:default'), 'unknown')
     # Cleanup test.
     profile_registry.unregisterProfile('default', 'newproduct')
     profile_registry.unregisterProfile('default', 'installed')
     profile_registry.unregisterProfile('default', 'uninstalled')
예제 #6
0
 def testCleanupUninstalledProducts(self):
     from plone.app.upgrade.v43.final import cleanupUninstalledProducts
     qi = getToolByName(self.portal, 'portal_quickinstaller')
     setup = getToolByName(self.portal, 'portal_setup')
     # Register three profiles.  I wanted to take 'new' as product
     # id, but there is already a python module 'new', so that goes
     # wrong.
     profile_registry.registerProfile('default',
                                      '',
                                      '',
                                      '/my/path',
                                      product='newproduct',
                                      profile_type=EXTENSION)
     profile_registry.registerProfile('default',
                                      '',
                                      '',
                                      '/my/path',
                                      product='installed',
                                      profile_type=EXTENSION)
     profile_registry.registerProfile('default',
                                      '',
                                      '',
                                      '/my/path',
                                      product='uninstalled',
                                      profile_type=EXTENSION)
     # Mark as installed.
     setup.setLastVersionForProfile('newproduct:default', '1')
     setup.setLastVersionForProfile('installed:default', '1')
     setup.setLastVersionForProfile('uninstalled:default', '1')
     # Notify of installation of three products.
     qi.notifyInstalled('newproduct', status='new')
     qi.notifyInstalled('installed', status='installed')
     qi.notifyInstalled('uninstalled', status='uninstalled')
     # The status differs, so QI does not think all are actually
     # installed.
     self.assertFalse(qi.isProductInstalled('newproduct'))
     self.assertTrue(qi.isProductInstalled('installed'))
     self.assertFalse(qi.isProductInstalled('uninstalled'))
     # But all three have an object in the QI.
     self.assertTrue('newproduct' in qi)
     self.assertTrue('installed' in qi)
     self.assertTrue('uninstalled' in qi)
     # And all three have a version in GS.
     self.assertEqual(setup.getLastVersionForProfile('newproduct:default'),
                      ('1', ))
     self.assertEqual(setup.getLastVersionForProfile('installed:default'),
                      ('1', ))
     self.assertEqual(setup.getLastVersionForProfile('uninstalled:default'),
                      ('1', ))
     # Call our cleanup function.
     cleanupUninstalledProducts(setup)
     # Same results for isProductInstalled.
     self.assertFalse(qi.isProductInstalled('newproduct'))
     self.assertTrue(qi.isProductInstalled('installed'))
     self.assertFalse(qi.isProductInstalled('uninstalled'))
     # The two not installed items are removed.
     self.assertFalse('newproduct' in qi)
     self.assertTrue('installed' in qi)
     self.assertFalse('uninstalled' in qi)
     # Those twee are unknown in GS.
     self.assertEqual(setup.getLastVersionForProfile('newproduct:default'),
                      'unknown')
     self.assertEqual(setup.getLastVersionForProfile('installed:default'),
                      ('1', ))
     self.assertEqual(setup.getLastVersionForProfile('uninstalled:default'),
                      'unknown')
     # Cleanup test.
     profile_registry.unregisterProfile('default', 'newproduct')
     profile_registry.unregisterProfile('default', 'installed')
     profile_registry.unregisterProfile('default', 'uninstalled')