当前位置: 首页>>代码示例>>Python>>正文


Python DummyImportContext._files[TOOLSET_XML]方法代码示例

本文整理汇总了Python中common.DummyImportContext._files[TOOLSET_XML]方法的典型用法代码示例。如果您正苦于以下问题:Python DummyImportContext._files[TOOLSET_XML]方法的具体用法?Python DummyImportContext._files[TOOLSET_XML]怎么用?Python DummyImportContext._files[TOOLSET_XML]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.DummyImportContext的用法示例。


在下文中一共展示了DummyImportContext._files[TOOLSET_XML]方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_import_updates_registry

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_import_updates_registry(self):
        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset
        from test_registry import _NORMAL_TOOLSET_XML

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

        # Import forbidden
        context._files[ TOOLSET_XML ] = _FORBIDDEN_TOOLSET_XML
        importToolset( context )

        tool = context.getSetupTool()
        toolset = tool.getToolsetRegistry()

        self.assertEqual( len( toolset.listForbiddenTools() ), 3 )
        self.failUnless( 'doomed' in toolset.listForbiddenTools() )
        self.failUnless( 'damned' in toolset.listForbiddenTools() )
        self.failUnless( 'blasted' in toolset.listForbiddenTools() )

        # Import required
        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
        importToolset( context )

        self.assertEqual( len( toolset.listRequiredTools() ), 2 )
        self.failUnless( 'mandatory' in toolset.listRequiredTools() )
        info = toolset.getRequiredToolInfo( 'mandatory' )
        self.assertEqual( info[ 'class' ],
                          'Products.GenericSetup.tests.test_tool.DummyTool' )
        self.failUnless( 'obligatory' in toolset.listRequiredTools() )
        info = toolset.getRequiredToolInfo( 'obligatory' )
        self.assertEqual( info[ 'class' ],
                          'Products.GenericSetup.tests.test_tool.DummyTool' )
开发者ID:dtgit,项目名称:dtedu,代码行数:35,代码来源:test_tool.py

示例2: test_forbidden_tools

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_forbidden_tools( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset
        TOOL_IDS = ( 'doomed', 'blasted', 'saved' )

        site = self._initSite()

        for tool_id in TOOL_IDS:
            pseudo = Folder()
            pseudo._setId( tool_id )
            site._setObject( tool_id, pseudo )

        self.assertEqual( len( site.objectIds() ), len( TOOL_IDS ) + 1 )

        for tool_id in TOOL_IDS:
            self.failUnless( tool_id in site.objectIds() )

        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _FORBIDDEN_TOOLSET_XML

        importToolset( context )

        self.assertEqual( len( site.objectIds() ), 2 )
        self.failUnless( 'setup_tool' in site.objectIds() )
        self.failUnless( 'saved' in site.objectIds() )
开发者ID:dtgit,项目名称:dtedu,代码行数:28,代码来源:test_tool.py

示例3: test_required_tools_missing_acquired_nofail

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_required_tools_missing_acquired_nofail( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset

        site = self._initSite()
        parent_site = Folder()

        mandatory = AnotherDummyTool()
        mandatory._setId( 'mandatory' )
        parent_site._setObject( 'mandatory', mandatory )

        obligatory = AnotherDummyTool()
        obligatory._setId( 'obligatory' )
        parent_site._setObject( 'obligatory', obligatory )

        site = site.__of__(parent_site)

        # acquiring subobjects of a different class during import
        # should not prevent new objects from being created if they
        # don't exist in the site

        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML

        importToolset( context )

        self.failIf( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
        self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
                                   , DummyTool ) )

        self.failIf( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
        self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
                                   , DummyTool ) )
开发者ID:dtgit,项目名称:dtedu,代码行数:36,代码来源:test_tool.py

示例4: test_required_tools_with_replacement

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_required_tools_with_replacement( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset

        site = self._initSite()

        mandatory = AnotherDummyTool()
        mandatory._setId( 'mandatory' )
        site._setObject( 'mandatory', mandatory )

        obligatory = AnotherDummyTool()
        obligatory._setId( 'obligatory' )
        site._setObject( 'obligatory', obligatory )

        self.assertEqual( len( site.objectIds() ), 3 )

        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML

        importToolset( context )

        self.assertEqual( len( site.objectIds() ), 3 )

        self.failIf( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
        self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
                                   , DummyTool ) )

        self.failIf( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
        self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
                                   , DummyTool ) )
开发者ID:dtgit,项目名称:dtedu,代码行数:33,代码来源:test_tool.py

示例5: test_required_tools_no_replacement

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_required_tools_no_replacement( self ):

        from Products.CMFSetup.tool import TOOLSET_XML
        from Products.CMFSetup.tool import importToolset

        site = self._initSite()

        mandatory = DummyTool()
        mandatory._setId( 'mandatory' )
        site._setObject( 'mandatory', mandatory )

        obligatory = DummyTool()
        obligatory._setId( 'obligatory' )
        site._setObject( 'obligatory', obligatory )

        self.assertEqual( len( site.objectIds() ), 3 )

        context = DummyImportContext( site )
        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML

        importToolset( context )

        self.assertEqual( len( site.objectIds() ), 3 )
        self.failUnless( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
        self.failUnless( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
开发者ID:goschtl,项目名称:zope,代码行数:27,代码来源:test_tool.py

示例6: test_applyContext

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_applyContext(self):
        from Products.GenericSetup.tool import IMPORT_STEPS_XML
        from Products.GenericSetup.tool import EXPORT_STEPS_XML
        from Products.GenericSetup.tool import TOOLSET_XML
        from test_registry import _SINGLE_IMPORT_XML
        from test_registry import _SINGLE_EXPORT_XML
        from test_registry import _NORMAL_TOOLSET_XML
        from test_registry import ONE_FUNC

        site = self._makeSite()
        tool = self._makeOne('setup_tool').__of__(site)
        tool.getImportStepRegistry().clear()
        tool.getExportStepRegistry().clear()
        tool.getToolsetRegistry().clear()

        context = DummyImportContext( site, tool=tool )
        context._files[ IMPORT_STEPS_XML ] = _SINGLE_IMPORT_XML
        context._files[ EXPORT_STEPS_XML ] = _SINGLE_EXPORT_XML
        context._files[ TOOLSET_XML ] = _NORMAL_TOOLSET_XML

        tool.applyContext(context)

        import_registry = tool.getImportStepRegistry()
        self.assertEqual( len( import_registry.listSteps() ), 1 )
        self.failUnless( 'one' in import_registry.listSteps() )
        info = import_registry.getStepMetadata( 'one' )
        self.assertEqual( info[ 'id' ], 'one' )
        self.assertEqual( info[ 'title' ], 'One Step' )
        self.assertEqual( info[ 'version' ], '1' )
        self.failUnless( 'One small step' in info[ 'description' ] )
        self.assertEqual( info[ 'handler' ]
                        , 'Products.GenericSetup.tests.test_registry.ONE_FUNC' )

        self.assertEqual( import_registry.getStep( 'one' ), ONE_FUNC )

        export_registry = tool.getExportStepRegistry()
        self.assertEqual( len( export_registry.listSteps() ), 1 )
        self.failUnless( 'one' in import_registry.listSteps() )
        info = export_registry.getStepMetadata( 'one' )
        self.assertEqual( info[ 'id' ], 'one' )
        self.assertEqual( info[ 'title' ], 'One Step' )
        self.failUnless( 'One small step' in info[ 'description' ] )
        self.assertEqual( info[ 'handler' ]
                        , 'Products.GenericSetup.tests.test_registry.ONE_FUNC' )

        self.assertEqual( export_registry.getStep( 'one' ), ONE_FUNC )

        toolset = tool.getToolsetRegistry()
        self.assertEqual( len( toolset.listForbiddenTools() ), 1 )
        self.failUnless( 'doomed' in toolset.listForbiddenTools() )
        self.assertEqual( len( toolset.listRequiredTools() ), 2 )
        self.failUnless( 'mandatory' in toolset.listRequiredTools() )
        info = toolset.getRequiredToolInfo( 'mandatory' )
        self.assertEqual( info[ 'class' ], 'path.to.one' )
        self.failUnless( 'obligatory' in toolset.listRequiredTools() )
        info = toolset.getRequiredToolInfo( 'obligatory' )
        self.assertEqual( info[ 'class' ], 'path.to.another' )
开发者ID:goschtl,项目名称:zope,代码行数:59,代码来源:test_tool.py

示例7: test_tool_id_required

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_tool_id_required(self):
        # Tests that tool creation will still work when an id is required
        # by the tool constructor.
        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset

        site = self._initSite()
        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _WITH_ID_TOOLSET_XML

        importToolset( context )

        for tool_id in ( 'mandatory', 'requires_id' ):
            tool = getattr( site, tool_id )
            self.assertEqual( tool.getId(), tool_id )
开发者ID:dtgit,项目名称:dtedu,代码行数:17,代码来源:test_tool.py

示例8: test_tool_ids

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_tool_ids( self ):
        # The tool import mechanism used to rely on the fact that all tools
        # have unique IDs set at the class level and that you can call their
        # constructor with no arguments. However, there might be tools
        # that need IDs set.
        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset

        site = self._initSite()
        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML

        importToolset( context )

        for tool_id in ( 'mandatory', 'obligatory' ):
            tool = getattr( site, tool_id )
            self.assertEqual( tool.getId(), tool_id )
开发者ID:dtgit,项目名称:dtedu,代码行数:19,代码来源:test_tool.py

示例9: test_required_tools_missing

# 需要导入模块: from common import DummyImportContext [as 别名]
# 或者: from common.DummyImportContext import _files[TOOLSET_XML] [as 别名]
    def test_required_tools_missing( self ):

        from Products.GenericSetup.tool import TOOLSET_XML
        from Products.GenericSetup.tool import importToolset

        site = self._initSite()
        self.assertEqual( len( site.objectIds() ), 1 )

        context = DummyImportContext( site, tool=site.setup_tool )
        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML

        importToolset( context )

        self.assertEqual( len( site.objectIds() ), 3 )
        self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
                                   , DummyTool ) )
        self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
                                   , DummyTool ) )
开发者ID:dtgit,项目名称:dtedu,代码行数:20,代码来源:test_tool.py


注:本文中的common.DummyImportContext._files[TOOLSET_XML]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。