[CMF-checkins] CVS: CMF/CMFCore/tests - test_WorkflowTool.py:1.3

Tres Seaver tseaver@zope.com
Fri, 5 Jul 2002 09:43:12 -0400


Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv12143/CMFCore/tests

Modified Files:
	test_WorkflowTool.py 
Log Message:



  - Made the workflow tool compute chains using type names, as well
    as instances (Tracker #441).


=== CMF/CMFCore/tests/test_WorkflowTool.py 1.2 => 1.3 ===
     def listTypeInfo( self ):
         return [ DummyTypeInfo( 'DummyContent' ) ]
+
+    def getTypeInfo( self, ob ):
+        if getattr( ob, 'meta_type', None ) is 'DummyContent':
+            return DummyTypeInfo( 'DummyContent' )
+        return None
         
 
 class WorkflowToolTests( unittest.TestCase ):
@@ -123,10 +128,13 @@
         root._setObject( 'portal_types', tt )
         return root
 
+    def _makeWithTypes( self ):
+        root = self._makeRoot()
+        return self._makeOne( workflow_ids=( 'a', 'b' ) ).__of__( root )
+
     def _makeWithTypesAndChain( self ):
 
-        root = self._makeRoot()
-        tool = self._makeOne( workflow_ids=( 'a', 'b' ) ).__of__( root )
+        tool = self._makeWithTypes()
         tool.setChainForPortalTypes( ( 'DummyContent', ), ( 'a', 'b' ) )
         return tool
 
@@ -157,7 +165,7 @@
 
         from Products.CMFCore.WorkflowTool import WorkflowException
 
-        tool = self._makeOne( workflow_ids=( 'a', 'b' ) )
+        tool = self._makeWithTypes()
 
         wfids = tool.getWorkflowIds()
         self.assertEqual( len( wfids ), 2 )
@@ -174,14 +182,14 @@
 
     def test_nonContent( self ):
 
-        tool = self._makeOne( workflow_ids=( 'a', 'b' ) )
+        tool = self._makeWithTypesAndChain()
         self.assertEquals( len( tool.getDefaultChainFor( None ) ), 0 )
         self.assertEquals( len( tool.getChainFor( None ) ), 0 )
         self.assertEquals( len( tool.getCatalogVariablesFor( None ) ), 0 )
 
     def test_content_default_chain( self ):
 
-        tool = self._makeOne( workflow_ids=( 'a', 'b' ) )
+        tool = self._makeWithTypes()
         dummy = DummyContent( 'dummy' )
         self.assertEquals( len( tool.getDefaultChainFor( dummy ) ), 1 )
         self.assertEquals( len( tool.getChainFor( dummy ) ), 1 )