Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
GenericSetup.tests.test_tool.Test_importToolset Class Reference
Inheritance diagram for GenericSetup.tests.test_tool.Test_importToolset:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.tests.test_tool.Test_importToolset:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_import_updates_registry
def test_tool_ids
def test_tool_id_required
def test_forbidden_tools
def test_required_tools_missing
def test_required_tools_no_replacement
def test_required_tools_with_replacement
def test_required_tools_missing_acquired_nofail

Static Public Attributes

 layer = ExportImportZCMLLayer

Detailed Description

Definition at line 1152 of file test_tool.py.


Member Function Documentation

Definition at line 1224 of file test_tool.py.

01224 
01225     def test_forbidden_tools( self ):
01226 
01227         from Products.GenericSetup.tool import TOOLSET_XML
01228         from Products.GenericSetup.tool import importToolset
01229         TOOL_IDS = ( 'doomed', 'blasted', 'saved' )
01230 
01231         site = self._initSite()
01232 
01233         for tool_id in TOOL_IDS:
01234             pseudo = Folder()
01235             pseudo._setId( tool_id )
01236             site._setObject( tool_id, pseudo )
01237 
01238         self.assertEqual( len( site.objectIds() ), len( TOOL_IDS ) + 1 )
01239 
01240         for tool_id in TOOL_IDS:
01241             self.failUnless( tool_id in site.objectIds() )
01242 
01243         context = DummyImportContext( site, tool=site.setup_tool )
01244         context._files[ TOOLSET_XML ] = _FORBIDDEN_TOOLSET_XML
01245 
01246         importToolset( context )
01247 
01248         self.assertEqual( len( site.objectIds() ), 2 )
01249         self.failUnless( 'setup_tool' in site.objectIds() )
01250         self.failUnless( 'saved' in site.objectIds() )

Here is the call graph for this function:

Definition at line 1156 of file test_tool.py.

01156 
01157     def test_import_updates_registry(self):
01158         from Products.GenericSetup.tool import TOOLSET_XML
01159         from Products.GenericSetup.tool import importToolset
01160         from test_registry import _NORMAL_TOOLSET_XML
01161 
01162         site = self._initSite()
01163         context = DummyImportContext( site, tool=site.setup_tool )
01164 
01165         # Import forbidden
01166         context._files[ TOOLSET_XML ] = _FORBIDDEN_TOOLSET_XML
01167         importToolset( context )
01168 
01169         tool = context.getSetupTool()
01170         toolset = tool.getToolsetRegistry()
01171 
01172         self.assertEqual( len( toolset.listForbiddenTools() ), 3 )
01173         self.failUnless( 'doomed' in toolset.listForbiddenTools() )
01174         self.failUnless( 'damned' in toolset.listForbiddenTools() )
01175         self.failUnless( 'blasted' in toolset.listForbiddenTools() )
01176 
01177         # Import required
01178         context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
01179         importToolset( context )
01180 
01181         self.assertEqual( len( toolset.listRequiredTools() ), 2 )
01182         self.failUnless( 'mandatory' in toolset.listRequiredTools() )
01183         info = toolset.getRequiredToolInfo( 'mandatory' )
01184         self.assertEqual( info[ 'class' ],
01185                           'Products.GenericSetup.tests.test_tool.DummyTool' )
01186         self.failUnless( 'obligatory' in toolset.listRequiredTools() )
01187         info = toolset.getRequiredToolInfo( 'obligatory' )
01188         self.assertEqual( info[ 'class' ],
01189                           'Products.GenericSetup.tests.test_tool.DummyTool' )

Here is the call graph for this function:

Definition at line 1251 of file test_tool.py.

01251 
01252     def test_required_tools_missing( self ):
01253 
01254         from Products.GenericSetup.tool import TOOLSET_XML
01255         from Products.GenericSetup.tool import importToolset
01256 
01257         site = self._initSite()
01258         self.assertEqual( len( site.objectIds() ), 1 )
01259 
01260         context = DummyImportContext( site, tool=site.setup_tool )
01261         context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
01262 
01263         importToolset( context )
01264 
01265         self.assertEqual( len( site.objectIds() ), 3 )
01266         self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
01267                                    , DummyTool ) )
01268         self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
01269                                    , DummyTool ) )

Here is the call graph for this function:

Definition at line 1328 of file test_tool.py.

01328 
01329     def test_required_tools_missing_acquired_nofail( self ):
01330 
01331         from Products.GenericSetup.tool import TOOLSET_XML
01332         from Products.GenericSetup.tool import importToolset
01333 
01334         site = self._initSite()
01335         parent_site = Folder()
01336 
01337         mandatory = AnotherDummyTool()
01338         mandatory._setId( 'mandatory' )
01339         parent_site._setObject( 'mandatory', mandatory )
01340 
01341         obligatory = AnotherDummyTool()
01342         obligatory._setId( 'obligatory' )
01343         parent_site._setObject( 'obligatory', obligatory )
01344 
01345         site = site.__of__(parent_site)
01346 
01347         # acquiring subobjects of a different class during import
01348         # should not prevent new objects from being created if they
01349         # don't exist in the site
01350 
01351         context = DummyImportContext( site, tool=site.setup_tool )
01352         context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
01353 
01354         importToolset( context )
01355 
01356         self.failIf( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
01357         self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
01358                                    , DummyTool ) )
01359 
01360         self.failIf( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
01361         self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
01362                                    , DummyTool ) )
01363 

Here is the call graph for this function:

Definition at line 1270 of file test_tool.py.

01270 
01271     def test_required_tools_no_replacement( self ):
01272 
01273         from Products.GenericSetup.tool import TOOLSET_XML
01274         from Products.GenericSetup.tool import importToolset
01275 
01276         site = self._initSite()
01277 
01278         mandatory = DummyTool()
01279         mandatory._setId( 'mandatory' )
01280         site._setObject( 'mandatory', mandatory )
01281 
01282         obligatory = DummyTool()
01283         obligatory._setId( 'obligatory' )
01284         site._setObject( 'obligatory', obligatory )
01285 
01286         self.assertEqual( len( site.objectIds() ), 3 )
01287 
01288         context = DummyImportContext( site, tool=site.setup_tool )
01289         context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
01290 
01291         importToolset( context )
01292 
01293         self.assertEqual( len( site.objectIds() ), 3 )
01294         self.failUnless( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
01295         self.failUnless( aq_base( site._getOb( 'obligatory' ) ) is obligatory )

Here is the call graph for this function:

Definition at line 1296 of file test_tool.py.

01296 
01297     def test_required_tools_with_replacement( self ):
01298 
01299         from Products.GenericSetup.tool import TOOLSET_XML
01300         from Products.GenericSetup.tool import importToolset
01301 
01302         site = self._initSite()
01303 
01304         mandatory = AnotherDummyTool()
01305         mandatory._setId( 'mandatory' )
01306         site._setObject( 'mandatory', mandatory )
01307 
01308         obligatory = AnotherDummyTool()
01309         obligatory._setId( 'obligatory' )
01310         site._setObject( 'obligatory', obligatory )
01311 
01312         self.assertEqual( len( site.objectIds() ), 3 )
01313 
01314         context = DummyImportContext( site, tool=site.setup_tool )
01315         context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
01316 
01317         importToolset( context )
01318 
01319         self.assertEqual( len( site.objectIds() ), 3 )
01320 
01321         self.failIf( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
01322         self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
01323                                    , DummyTool ) )
01324 
01325         self.failIf( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
01326         self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
01327                                    , DummyTool ) )

Here is the call graph for this function:

Definition at line 1208 of file test_tool.py.

01208 
01209     def test_tool_id_required(self):
01210         # Tests that tool creation will still work when an id is required
01211         # by the tool constructor.
01212         from Products.GenericSetup.tool import TOOLSET_XML
01213         from Products.GenericSetup.tool import importToolset
01214 
01215         site = self._initSite()
01216         context = DummyImportContext( site, tool=site.setup_tool )
01217         context._files[ TOOLSET_XML ] = _WITH_ID_TOOLSET_XML
01218 
01219         importToolset( context )
01220 
01221         for tool_id in ( 'mandatory', 'requires_id' ):
01222             tool = getattr( site, tool_id )
01223             self.assertEqual( tool.getId(), tool_id )

Here is the call graph for this function:

Definition at line 1190 of file test_tool.py.

01190 
01191     def test_tool_ids( self ):
01192         # The tool import mechanism used to rely on the fact that all tools
01193         # have unique IDs set at the class level and that you can call their
01194         # constructor with no arguments. However, there might be tools
01195         # that need IDs set.
01196         from Products.GenericSetup.tool import TOOLSET_XML
01197         from Products.GenericSetup.tool import importToolset
01198 
01199         site = self._initSite()
01200         context = DummyImportContext( site, tool=site.setup_tool )
01201         context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
01202 
01203         importToolset( context )
01204 
01205         for tool_id in ( 'mandatory', 'obligatory' ):
01206             tool = getattr( site, tool_id )
01207             self.assertEqual( tool.getId(), tool_id )

Here is the call graph for this function:


Member Data Documentation

Definition at line 1154 of file test_tool.py.


The documentation for this class was generated from the following file: