예제 #1
0
    def test_normal( self ):

        _IDS = ( 'one', 'two', 'three' )
        _FSDVS = [ ( id, DummyFSDV( id ) ) for id in _IDS ]
        _PATHS = { 'basic' : 'one'
                 , 'fancy' : 'three, two, one'
                 }

        site = self._initSite( selections=_PATHS, fsdvs=_FSDVS )
        tool = site.portal_skins
        tool.default_skin = 'basic'
        tool.request_varname = 'skin_var'
        tool.allow_any = True
        tool.cookie_persistence = True

        context = DummyExportContext( site )

        from Products.CMFSetup.skins import exportSkinsTool
        exportSkinsTool( context )

        self.assertEqual( len( context._wrote ), 1 )
        filename, text, content_type = context._wrote[ 0 ]
        self.assertEqual( filename, 'skins.xml' )
        self._compareDOM( text, _NORMAL_EXPORT )
        self.assertEqual( content_type, 'text/xml' )
예제 #2
0
    def test_i18n(self):

        from Products.CMFSetup.actions import importActionProviders

        site = self._initSite(0, 0)
        atool = site.portal_actions

        context = DummyImportContext(site)
        context._files['actions.xml'] = _I18N_IMPORT
        importActionProviders(context)

        self.assertEqual(len(atool.listActionProviders()), 1)
        self.assertEqual(atool.objectIds(), ['dummy'])
        self.assertEqual(atool.dummy.objectIds(), ['foo'])
        self.assertEqual(atool.dummy.foo.i18n_domain, 'foo_domain')

        # complete the roundtrip
        context = DummyExportContext(site)
        from Products.CMFSetup.actions import exportActionProviders
        exportActionProviders(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'actions.xml')
        self._compareDOM(text, _I18N_IMPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #3
0
    def test_normal_purge(self):
        from Products.CMFSetup.catalog import exportCatalogTool
        from Products.CMFSetup.catalog import importCatalogTool

        site = self._initSite(2)
        ctool = site.portal_catalog

        self.assertEqual(len(ctool.objectIds()), 1)
        self.assertEqual(len(ctool.indexes()), 1)
        self.assertEqual(len(ctool.schema()), 1)

        context = DummyImportContext(site, True)
        context._files['catalog.xml'] = _NORMAL_EXPORT
        importCatalogTool(context)

        self.assertEqual(len(ctool.objectIds()), 1)
        self.assertEqual(len(ctool.indexes()), 1)
        self.assertEqual(len(ctool.schema()), 1)

        # complete the roundtrip
        context = DummyExportContext(site)
        exportCatalogTool(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'catalog.xml')
        self._compareDOM(text, _NORMAL_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #4
0
    def test_old_xml(self):
        from Products.CMFSetup.typeinfo import exportTypesTool
        from Products.CMFSetup.typeinfo import importTypesTool

        site = self._initSite()
        tool = site.portal_types

        self.assertEqual(len(tool.objectIds()), 0)

        context = DummyImportContext(site)
        context._files['typestool.xml'] = _NORMAL_TOOL_EXPORT
        context._files['types/foo.xml'] = _FOO_OLD_EXPORT % 'foo'
        context._files['types/bar.xml'] = _BAR_OLD_EXPORT % 'bar'
        importTypesTool(context)

        self.assertEqual(len(tool.objectIds()), 2)
        self.failUnless('foo' in tool.objectIds())
        self.failUnless('bar' in tool.objectIds())

        context = DummyExportContext(site)
        exportTypesTool(context)

        filename, text, content_type = context._wrote[1]
        self.assertEqual(filename, 'types/bar.xml')
        self._compareDOM(text, _BAR_EXPORT % 'bar')
        self.assertEqual(content_type, 'text/xml')
예제 #5
0
    def test_empty(self):
        from Products.CMFSetup.typeinfo import exportTypesTool

        site = self._initSite()
        context = DummyExportContext(site)
        exportTypesTool(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'typestool.xml')
        self._compareDOM(text, _EMPTY_TOOL_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #6
0
    def test_changed(self):
        from Products.CMFSetup.cookieauth import exportCookieCrumbler

        site = self._initSite(use_changed=True)
        context = DummyExportContext(site)
        exportCookieCrumbler(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'cookieauth.xml')
        self._compareDOM(text, _CHANGED_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #7
0
    def test_normal(self):
        from Products.CMFSetup.catalog import exportCatalogTool

        site = self._initSite(2)
        context = DummyExportContext(site)
        exportCatalogTool(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'catalog.xml')
        self._compareDOM(text, _NORMAL_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #8
0
    def test_changed(self):
        from Products.CMFSetup.mailhost import exportMailHost

        site = self._initSite(use_changed=True)
        context = DummyExportContext(site)
        exportMailHost(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'mailhost.xml')
        self._compareDOM(text, _CHANGED_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #9
0
    def test_normal(self):

        site = self._initSite()
        context = DummyExportContext(site)

        from Products.CMFSetup.properties import exportSiteProperties
        exportSiteProperties(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'properties.xml')
        self._compareDOM(text, _NORMAL_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #10
0
    def test_empty(self):

        site = self._initSite()
        context = DummyExportContext(site)

        from Products.CMFSetup.skins import exportSkinsTool
        exportSkinsTool(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'skins.xml')
        self._compareDOM(text, _EMPTY_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #11
0
    def test_with_policy(self):
        from Products.CMFSetup.cachingpolicymgr \
            import exportCachingPolicyManager

        site = self._initSite(with_policy=True)
        context = DummyExportContext(site)
        exportCachingPolicyManager(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'cachingpolicymgr.xml')
        self._compareDOM(text, self._WITH_POLICY_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #12
0
    def test_unchanged(self):

        site = self._initSite(0, 0)
        context = DummyExportContext(site)

        from Products.CMFSetup.actions import exportActionProviders
        exportActionProviders(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'actions.xml')
        self._compareDOM(text, _EMPTY_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #13
0
    def test_with_policy(self):
        from Products.CMFSetup.contenttyperegistry \
            import exportContentTypeRegistry

        site = self._initSite(mit_predikat=True)
        context = DummyExportContext(site)
        exportContentTypeRegistry(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'contenttyperegistry.xml')
        self._compareDOM(text, self._WITH_POLICY_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #14
0
    def test_unchanged(self):

        self.app.site = Folder('site')
        site = self.app.site

        context = DummyExportContext(site)

        from Products.GenericSetup.rolemap import exportRolemap
        exportRolemap(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'rolemap.xml')
        self._compareDOM(text, _EMPTY_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #15
0
    def test_empty( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import exportToolset

        site = self._initSite()
        context = DummyExportContext( site, tool=site.setup_tool )

        exportToolset( context )

        self.assertEqual( len( context._wrote ), 1 )
        filename, text, content_type = context._wrote[ 0 ]
        self.assertEqual( filename, TOOLSET_XML )
        self._compareDOM( text, _EMPTY_TOOLSET_XML )
        self.assertEqual( content_type, 'text/xml' )
예제 #16
0
    def test_added_role(self):

        self.app.site = Folder('site')
        site = self.app.site
        existing_roles = list(getattr(site, '__ac_roles__', []))[:]
        existing_roles.append('ZZZ')
        site.__ac_roles__ = existing_roles

        context = DummyExportContext(site)

        from Products.GenericSetup.rolemap import exportRolemap
        exportRolemap(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'rolemap.xml')
        self._compareDOM(text, _ADDED_ROLE_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #17
0
    def test_unacquired_perm_added_role(self):

        ACI = 'Access contents information'
        ROLES = ['Manager', 'Owner']

        self.app.site = Folder('site')
        site = self.app.site
        site.manage_permission(ACI, ROLES)

        context = DummyExportContext(site)

        from Products.GenericSetup.rolemap import exportRolemap
        exportRolemap(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'rolemap.xml')
        self._compareDOM(text, _UNACQUIRED_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #18
0
    def test_normal(self):

        site = self._initSite(1, 1)
        atool = site.portal_actions
        foo = site.portal_foo
        bar = site.portal_bar

        self.assertEqual(len(atool.listActionProviders()), 1)
        self.failIf('portal_foo' in atool.listActionProviders())
        self.failIf(foo.listActions())
        self.failIf('portal_bar' in atool.listActionProviders())
        self.failIf(bar.listActions())
        self.failUnless('portal_actions' in atool.listActionProviders())

        context = DummyImportContext(site)
        context._files['actions.xml'] = _NORMAL_EXPORT

        from Products.CMFSetup.actions import importActionProviders
        importActionProviders(context)

        self.assertEqual(len(atool.listActionProviders()), 1)
        self.failIf('portal_foo' in atool.listActionProviders())
        self.failUnless('portal_actions' in atool.listActionProviders())

        self.assertEqual(len(atool.objectIds()), 1)
        self.failUnless('dummy' in atool.objectIds())
        self.assertEqual(len(atool.dummy.objectIds()), 2)
        self.failUnless('foo' in atool.dummy.objectIds())
        self.failUnless('bar' in atool.dummy.objectIds())
        self.failIf(foo.listActions())
        self.failIf(bar.listActions())

        # complete the roundtrip
        context = DummyExportContext(site)
        from Products.CMFSetup.actions import exportActionProviders
        exportActionProviders(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'actions.xml')
        self._compareDOM(text, _NEWSYTLE_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #19
0
    def test_normal( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import exportToolset

        site = self._initSite()
        toolset = site.setup_tool.getToolsetRegistry()
        toolset.addForbiddenTool( 'doomed' )
        toolset.addRequiredTool( 'mandatory', 'path.to.one' )
        toolset.addRequiredTool( 'obligatory', 'path.to.another' )

        context = DummyExportContext( site, tool=site.setup_tool )

        exportToolset( context )

        self.assertEqual( len( context._wrote ), 1 )
        filename, text, content_type = context._wrote[ 0 ]
        self.assertEqual( filename, TOOLSET_XML )
        self._compareDOM( text, _NORMAL_TOOLSET_XML )
        self.assertEqual( content_type, 'text/xml' )
예제 #20
0
    def test_unacquired_perm(self):

        ACI = 'Access contents information'
        ROLES = ['Manager', 'Owner', 'ZZZ']

        self.app.site = Folder('site')
        site = self.app.site
        existing_roles = list(getattr(site, '__ac_roles__', []))[:]
        existing_roles.append('ZZZ')
        site.__ac_roles__ = existing_roles
        site.manage_permission(ACI, ROLES)

        context = DummyExportContext(site)

        from Products.GenericSetup.rolemap import exportRolemap
        exportRolemap(context)

        self.assertEqual(len(context._wrote), 1)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'rolemap.xml')
        self._compareDOM(text, _COMBINED_EXPORT)
        self.assertEqual(content_type, 'text/xml')
예제 #21
0
    def test_normal(self):
        from Products.CMFSetup.typeinfo import exportTypesTool

        site = self._initSite(1)
        context = DummyExportContext(site)
        exportTypesTool(context)

        self.assertEqual(len(context._wrote), 3)
        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'typestool.xml')
        self._compareDOM(text, _NORMAL_TOOL_EXPORT)
        self.assertEqual(content_type, 'text/xml')

        filename, text, content_type = context._wrote[1]
        self.assertEqual(filename, 'types/bar.xml')
        self._compareDOM(text, _BAR_EXPORT % 'bar')
        self.assertEqual(content_type, 'text/xml')

        filename, text, content_type = context._wrote[2]
        self.assertEqual(filename, 'types/foo.xml')
        self._compareDOM(text, _FOO_EXPORT % 'foo')
        self.assertEqual(content_type, 'text/xml')
예제 #22
0
    def test_with_filenames(self):
        from Products.CMFSetup.typeinfo import exportTypesTool

        site = self._initSite(2)
        context = DummyExportContext(site)
        exportTypesTool(context)

        self.assertEqual(len(context._wrote), 3)

        filename, text, content_type = context._wrote[0]
        self.assertEqual(filename, 'typestool.xml')
        self._compareDOM(text, _FILENAME_EXPORT)
        self.assertEqual(content_type, 'text/xml')

        filename, text, content_type = context._wrote[1]
        self.assertEqual(filename, 'types/bar_object.xml')
        self._compareDOM(text, _BAR_EXPORT % 'bar object')
        self.assertEqual(content_type, 'text/xml')

        filename, text, content_type = context._wrote[2]
        self.assertEqual(filename, 'types/foo_object.xml')
        self._compareDOM(text, _FOO_EXPORT % 'foo object')
        self.assertEqual(content_type, 'text/xml')