[CMF-checkins] CVS: CMF/CMFSetup/tests - test_typeinfo.py:1.6
test_workflow.py:1.5
Tres Seaver
tseaver at zope.com
Thu Jun 3 19:11:36 EDT 2004
Update of /cvs-repository/CMF/CMFSetup/tests
In directory cvs.zope.org:/tmp/cvs-serv4618/tests
Modified Files:
test_typeinfo.py test_workflow.py
Log Message:
- workflow.py:
o Add 'listWorkflowChains' to support tool XML generation.
o Implement tool XML generation.
=== CMF/CMFSetup/tests/test_typeinfo.py 1.5 => 1.6 ===
--- CMF/CMFSetup/tests/test_typeinfo.py:1.5 Sun May 30 16:00:57 2004
+++ CMF/CMFSetup/tests/test_typeinfo.py Thu Jun 3 19:11:35 2004
@@ -215,13 +215,13 @@
site = self._initSite()
configurator = self._makeOne( site ).__of__( site )
- self._compareDOM( configurator.generateToolXML(), _EMPTY_EXPORT )
+ self._compareDOM( configurator.generateToolXML(), _EMPTY_TOOL_EXPORT )
def test_generateToolXML_normal( self ):
site = self._initSite( _TI_LIST )
configurator = self._makeOne( site ).__of__( site )
- self._compareDOM( configurator.generateToolXML(), _NORMAL_EXPORT )
+ self._compareDOM( configurator.generateToolXML(), _NORMAL_TOOL_EXPORT )
def test_generateToolXML_explicit_filename( self ):
@@ -248,7 +248,7 @@
site = self._initSite()
configurator = self._makeOne( site ).__of__( site )
- id_file_list = configurator.parseToolXML( _EMPTY_EXPORT )
+ id_file_list = configurator.parseToolXML( _EMPTY_TOOL_EXPORT )
self.assertEqual( len( id_file_list ), 0 )
def test_parseToolXML_normal( self ):
@@ -256,7 +256,7 @@
site = self._initSite()
configurator = self._makeOne( site ).__of__( site )
- id_file_list = configurator.parseToolXML( _NORMAL_EXPORT )
+ id_file_list = configurator.parseToolXML( _NORMAL_TOOL_EXPORT )
self.assertEqual( len( id_file_list ), 2 )
self.assertEqual( id_file_list[ 0 ][ 0 ], 'foo' )
@@ -407,13 +407,13 @@
duplicate[ 'id' ] = '%s object' % original[ 'id' ]
_TI_LIST_WITH_FILENAME.append( duplicate )
-_EMPTY_EXPORT = """\
+_EMPTY_TOOL_EXPORT = """\
<?xml version="1.0"?>
<types-tool>
</types-tool>
"""
-_NORMAL_EXPORT = """\
+_NORMAL_TOOL_EXPORT = """\
<?xml version="1.0"?>
<types-tool>
<type id="foo" />
@@ -549,7 +549,7 @@
self.assertEqual( len( context._wrote ), 1 )
filename, text, content_type = context._wrote[ 0 ]
self.assertEqual( filename, 'typestool.xml' )
- self._compareDOM( text, _EMPTY_EXPORT )
+ self._compareDOM( text, _EMPTY_TOOL_EXPORT )
self.assertEqual( content_type, 'text/xml' )
def test_normal( self ):
@@ -564,7 +564,7 @@
filename, text, content_type = context._wrote[ 0 ]
self.assertEqual( filename, 'typestool.xml' )
- self._compareDOM( text, _NORMAL_EXPORT )
+ self._compareDOM( text, _NORMAL_TOOL_EXPORT )
self.assertEqual( content_type, 'text/xml' )
filename, text, content_type = context._wrote[ 1 ]
@@ -612,7 +612,7 @@
self.assertEqual( len( tool.objectIds() ), 2 )
context = DummyImportContext( site )
- context._files[ 'typestool.xml' ] = _EMPTY_EXPORT
+ context._files[ 'typestool.xml' ] = _EMPTY_TOOL_EXPORT
from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool( context )
@@ -627,7 +627,7 @@
self.assertEqual( len( tool.objectIds() ), 2 )
context = DummyImportContext( site, True )
- context._files[ 'typestool.xml' ] = _EMPTY_EXPORT
+ context._files[ 'typestool.xml' ] = _EMPTY_TOOL_EXPORT
from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool( context )
@@ -642,7 +642,7 @@
self.assertEqual( len( tool.objectIds() ), 2 )
context = DummyImportContext( site, False )
- context._files[ 'typestool.xml' ] = _EMPTY_EXPORT
+ context._files[ 'typestool.xml' ] = _EMPTY_TOOL_EXPORT
from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool( context )
@@ -657,7 +657,7 @@
self.assertEqual( len( tool.objectIds() ), 0 )
context = DummyImportContext( site )
- context._files[ 'typestool.xml' ] = _NORMAL_EXPORT
+ context._files[ 'typestool.xml' ] = _NORMAL_TOOL_EXPORT
context._files[ 'types/foo.xml' ] = _FOO_EXPORT % 'foo'
context._files[ 'types/bar.xml' ] = _BAR_EXPORT % 'bar'
=== CMF/CMFSetup/tests/test_workflow.py 1.4 => 1.5 ===
--- CMF/CMFSetup/tests/test_workflow.py:1.4 Thu Jun 3 18:02:02 2004
+++ CMF/CMFSetup/tests/test_workflow.py Thu Jun 3 19:11:35 2004
@@ -16,6 +16,11 @@
class DummyWorkflowTool( Folder ):
+ def __init__( self, id='portal_workflow' ):
+ Folder.__init__( self, id )
+ self._default_chain = ()
+ self._chains_by_type = {}
+
def getWorkflowIds( self ):
return self.objectIds()
@@ -447,10 +452,6 @@
site = self._initSite()
- configurator = self._makeOne( site ).__of__( site )
-
- self.assertEqual( len( configurator.listWorkflowInfo() ), 0 )
-
WF_ID_NON = 'non_dcworkflow'
WF_TITLE_NON = 'Non-DCWorkflow'
WF_ID_DC = 'dcworkflow'
@@ -483,6 +484,120 @@
self.assertEqual( dc_info[ 'filename' ]
, 'workflows/%s/definition.xml' % WF_ID_DC )
+ def test_listWorkflowChains_no_default( self ):
+
+ site = self._initSite()
+ configurator = self._makeOne( site ).__of__( site )
+
+ chains = configurator.listWorkflowChains()
+
+ default_chain = [ x[1] for x in chains if x[0] is None ][0]
+ self.assertEqual( len( default_chain ), 0 )
+
+ def test_listWorkflowChains_with_default( self ):
+
+ site = self._initSite()
+ site.portal_workflow._default_chain = ( 'foo', 'bar' )
+ configurator = self._makeOne( site ).__of__( site )
+
+ chains = configurator.listWorkflowChains()
+
+ self.assertEqual( chains[ 0 ][ 0 ], None )
+ default_chain = chains[ 0 ][ 1 ]
+ self.assertEqual( len( default_chain ), 2 )
+ self.assertEqual( default_chain[ 0 ], 'foo' )
+ self.assertEqual( default_chain[ 1 ], 'bar' )
+
+ def test_listWorkflowChains_no_overrides( self ):
+
+ site = self._initSite()
+ configurator = self._makeOne( site ).__of__( site )
+
+ chains = configurator.listWorkflowChains()
+
+ self.assertEqual( len( chains ), 1 )
+
+ def test_listWorkflowChains_with_overrides( self ):
+
+ site = self._initSite()
+ site.portal_workflow._chains_by_type[ 'qux' ] = ( 'foo', 'bar' )
+ configurator = self._makeOne( site ).__of__( site )
+
+ chains = configurator.listWorkflowChains()
+
+ self.assertEqual( len( chains ), 2 )
+
+ self.assertEqual( chains[ 0 ][ 0 ], None )
+ default_chain = chains[ 0 ][ 1 ]
+ self.assertEqual( len( default_chain ), 0 )
+
+ self.assertEqual( chains[ 1 ][ 0 ], 'qux' )
+ qux_chain = chains[ 1 ][ 1 ]
+ self.assertEqual( len( qux_chain ), 2 )
+ self.assertEqual( qux_chain[ 0 ], 'foo' )
+ self.assertEqual( qux_chain[ 1 ], 'bar' )
+
+ def test_listWorkflowChains_default_chain_plus_overrides( self ):
+
+ site = self._initSite()
+ site.portal_workflow._default_chain = ( 'foo', 'bar' )
+ site.portal_workflow._chains_by_type[ 'qux' ] = ( 'baz', )
+ configurator = self._makeOne( site ).__of__( site )
+
+ chains = configurator.listWorkflowChains()
+
+ self.assertEqual( chains[ 0 ][ 0 ], None )
+ default_chain = chains[ 0 ][ 1 ]
+ self.assertEqual( len( default_chain ), 2 )
+ self.assertEqual( default_chain[ 0 ], 'foo' )
+ self.assertEqual( default_chain[ 1 ], 'bar' )
+
+ self.assertEqual( chains[ 1 ][ 0 ], 'qux' )
+ qux_chain = chains[ 1 ][ 1 ]
+ self.assertEqual( len( qux_chain ), 1 )
+ self.assertEqual( qux_chain[ 0 ], 'baz' )
+
+ def test_generateToolXML_empty( self ):
+
+ site = self._initSite()
+ configurator = self._makeOne( site ).__of__( site )
+ self._compareDOM( configurator.generateToolXML(), _EMPTY_TOOL_EXPORT )
+
+ def test_generateToolXML_default_chain_plus_overrides( self ):
+
+ site = self._initSite()
+ site.portal_workflow._default_chain = ( 'foo', 'bar' )
+ site.portal_workflow._chains_by_type[ 'qux' ] = ( 'baz', )
+
+ configurator = self._makeOne( site ).__of__( site )
+
+ self._compareDOM( configurator.generateToolXML()
+ , _OVERRIDE_TOOL_EXPORT )
+
+ def test_generateToolXML_mixed( self ):
+
+ site = self._initSite()
+
+ WF_ID_NON = 'non_dcworkflow'
+ WF_TITLE_NON = 'Non-DCWorkflow'
+ WF_ID_DC = 'dcworkflow'
+ WF_TITLE_DC = 'DCWorkflow'
+
+ site = self._initSite()
+
+ wf_tool = site.portal_workflow
+ nondcworkflow = DummyWorkflow( WF_TITLE_NON )
+ nondcworkflow.title = WF_TITLE_NON
+ wf_tool._setObject( WF_ID_NON, nondcworkflow )
+
+ dcworkflow = self._initDCWorkflow( WF_ID_DC )
+ dcworkflow.title = WF_TITLE_DC
+
+ configurator = self._makeOne( site ).__of__( site )
+
+ self._compareDOM( configurator.generateToolXML(), _NORMAL_TOOL_EXPORT )
+
+
_WF_PERMISSIONS = \
( 'Open content for modifications'
@@ -696,6 +811,50 @@
, _AFTER_KILL_SCRIPT
)
}
+
+_EMPTY_TOOL_EXPORT = """\
+<?xml version="1.0"?>
+<workflow-tool>
+ <bindings>
+ <default>
+ </default>
+ </bindings>
+</workflow-tool>
+"""
+
+_OVERRIDE_TOOL_EXPORT = """\
+<?xml version="1.0"?>
+<workflow-tool>
+ <bindings>
+ <default>
+ <bound-workflow workflow_id="foo" />
+ <bound-workflow workflow_id="bar" />
+ </default>
+ <type type_id="qux">
+ <bound-workflow workflow_id="baz" />
+ </type>
+ </bindings>
+</workflow-tool>
+"""
+
+_NORMAL_TOOL_EXPORT = """\
+<?xml version="1.0"?>
+<workflow-tool>
+ <workflow
+ workflow_id="non_dcworkflow"
+ meta_type="Dummy Workflow"
+ />
+ <workflow
+ workflow_id="dcworkflow"
+ filename="workflows/dcworkflow/definition.xml"
+ meta_type="Workflow"
+ />
+ <bindings>
+ <default>
+ </default>
+ </bindings>
+</workflow-tool>
+"""
def test_suite():
More information about the CMF-checkins
mailing list