Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
CMFCore.tests.test_WorkflowTool.WorkflowToolTests Class Reference

List of all members.

Public Member Functions

def tearDown
def test_z2interfaces
def test_z3interfaces
def test_empty
def test_new_with_wf
def test_nonContent
def test_notReallyContent
def test_content_default_chain
def test_content_own_chain
def test_setChainForPortalTypes
def test_getCatalogVariablesFor
def test_getInfoFor
def test_doActionFor
def test_notifyCreated
def test_notifyBefore
def test_notifySuccess
def test_notifyException
def xxx_test_updateRoleMappings

Private Member Functions

def _makeOne
def _makeRoot
def _makeWithTypes
def _makeWithTypesAndChain

Detailed Description

Definition at line 156 of file test_WorkflowTool.py.


Member Function Documentation

def CMFCore.tests.test_WorkflowTool.WorkflowToolTests._makeOne (   self,
  workflow_ids = () 
) [private]

Definition at line 158 of file test_WorkflowTool.py.

00158 
00159     def _makeOne( self, workflow_ids=() ):
00160         from Products.CMFCore.WorkflowTool import WorkflowTool
00161 
00162         tool = WorkflowTool()
00163 
00164         for workflow_id in workflow_ids:
00165             tool._setObject(workflow_id, DummyWorkflow(workflow_id))
00166 
00167         return tool

Definition at line 168 of file test_WorkflowTool.py.

00168 
00169     def _makeRoot( self ):
00170 
00171         from OFS.Folder import Folder
00172         root = Folder( 'root' )
00173         tt = DummyTypesTool()
00174         root._setObject( 'portal_types', tt )
00175         return root

Here is the caller graph for this function:

Definition at line 176 of file test_WorkflowTool.py.

00176 
00177     def _makeWithTypes( self ):
00178         root = self._makeRoot()
00179         return self._makeOne( workflow_ids=( 'a', 'b' ) ).__of__( root )

Here is the caller graph for this function:

Definition at line 180 of file test_WorkflowTool.py.

00180 
00181     def _makeWithTypesAndChain( self ):
00182 
00183         tool = self._makeWithTypes()
00184         tool.setChainForPortalTypes( ( 'Dummy Content', ), ( 'a', 'b' ) )
00185         return tool

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 186 of file test_WorkflowTool.py.

00186 
00187     def tearDown(self):
00188         cleanUp()

Here is the call graph for this function:

Definition at line 262 of file test_WorkflowTool.py.

00262 
00263     def test_content_default_chain( self ):
00264 
00265         tool = self._makeWithTypes()
00266         dummy = DummyContent( 'dummy' )
00267         self.assertEquals( len( tool.getDefaultChainFor( dummy ) ), 1 )
00268         self.assertEquals( len( tool.getDefaultChain() ), 1 )
00269         self.assertEquals( len( tool.listChainOverrides() ), 0 )
00270         self.assertEquals( len( tool.getChainFor( dummy ) ), 1 )
00271         self.assertEquals( len( tool.getCatalogVariablesFor( dummy ) ), 0 )
00272         self.assertEquals( tool.getDefaultChain(), tool.getChainFor( dummy ) )

Here is the call graph for this function:

Definition at line 273 of file test_WorkflowTool.py.

00273 
00274     def test_content_own_chain( self ):
00275 
00276         tool = self._makeWithTypesAndChain()
00277 
00278         dummy = DummyContent( 'dummy' )
00279 
00280         self.assertEquals( len( tool.getDefaultChainFor( dummy ) ), 1 )
00281         self.assertEquals( len( tool.getDefaultChain() ), 1 )
00282         self.assertEquals( len( tool.listChainOverrides() ), 1 )
00283         chain = tool.getChainFor( dummy )
00284         self.assertEquals( len( chain ), 2 )
00285         self.failUnless( 'a' in chain )
00286         self.failUnless( 'b' in chain )
00287 
00288         vars = tool.getCatalogVariablesFor( dummy )
00289         self.assertEquals( len( vars ), 1 )
00290         self.failUnless( 'dummy' in vars.keys() )
00291         self.failUnless( 'a: dummy' in vars.values() )

Here is the call graph for this function:

Definition at line 338 of file test_WorkflowTool.py.

00338 
00339     def test_doActionFor( self ):
00340 
00341         tool = self._makeWithTypesAndChain()
00342         tool.a.setKnownActions( ( 'action', ) )
00343         dummy = DummyContent( 'dummy' )
00344 
00345         tool.doActionFor( dummy, 'action' )
00346 
00347         self.failUnless( tool.a.didAction( 'action' ) )
00348         self.failIf( tool.b.didAction( 'action' ) )

Here is the call graph for this function:

Definition at line 211 of file test_WorkflowTool.py.

00211 
00212     def test_empty( self ):
00213 
00214         from Products.CMFCore.WorkflowTool import WorkflowException
00215 
00216         tool = self._makeOne()
00217 
00218         self.failIf( tool.getWorkflowIds() )
00219         self.assertEqual( tool.getWorkflowById( 'default_workflow' ), None )
00220         self.assertEqual( tool.getWorkflowById( 'a' ), None )
00221 
00222         self.assertRaises( WorkflowException, tool.getInfoFor, None, 'hmm' )
00223         self.assertRaises( WorkflowException, tool.doActionFor, None, 'hmm' )

Definition at line 316 of file test_WorkflowTool.py.

00316 
00317     def test_getCatalogVariablesFor( self ):
00318 
00319         tool = self._makeWithTypesAndChain()
00320         dummy = DummyContent( 'dummy' )
00321 
00322         vars = tool.getCatalogVariablesFor( dummy )
00323         self.assertEquals( len( vars ), 1 )
00324         self.failUnless( 'dummy' in vars.keys() )
00325         self.failUnless( 'a: dummy' in vars.values() )

Here is the call graph for this function:

Definition at line 326 of file test_WorkflowTool.py.

00326 
00327     def test_getInfoFor( self ):
00328 
00329         tool = self._makeWithTypesAndChain()
00330         tool.b.setKnownInfo( ( 'info', ) )
00331         dummy = DummyContent( 'dummy' )
00332 
00333         info = tool.getInfoFor( dummy, 'info' )
00334 
00335         self.assertEqual( info, 1 )
00336         self.failIf( tool.a.gaveInfo( 'info' ) )
00337         self.failUnless( tool.b.gaveInfo( 'info' ) )

Here is the call graph for this function:

Definition at line 224 of file test_WorkflowTool.py.

00224 
00225     def test_new_with_wf( self ):
00226 
00227         from Products.CMFCore.WorkflowTool import WorkflowException
00228 
00229         tool = self._makeWithTypes()
00230 
00231         wfids = tool.getWorkflowIds()
00232         self.assertEqual( len( wfids ), 2 )
00233         self.failUnless( 'a' in wfids )
00234         self.failUnless( 'b' in wfids )
00235         self.assertEqual( tool.getWorkflowById( 'default' ), None )
00236         wf = tool.getWorkflowById( 'a' )
00237         self.assertEqual( wf.getId(), 'a' )
00238         wf = tool.getWorkflowById( 'b' )
00239         self.assertEqual( wf.getId(), 'b' )
00240 
00241         self.assertRaises( WorkflowException, tool.getInfoFor, None, 'hmm' )
00242         self.assertRaises( WorkflowException, tool.doActionFor, None, 'hmm' )

Here is the call graph for this function:

Definition at line 243 of file test_WorkflowTool.py.

00243 
00244     def test_nonContent( self ):
00245 
00246         tool = self._makeWithTypesAndChain()
00247         self.assertEquals( len( tool.getDefaultChainFor( None ) ), 0 )
00248         self.assertEquals( len( tool.getDefaultChain() ), 1 )
00249         self.assertEquals( len( tool.listChainOverrides() ), 1 )
00250         self.assertEquals( len( tool.getChainFor( None ) ), 0 )
00251         self.assertEquals( len( tool.getCatalogVariablesFor( None ) ), 0 )

Here is the call graph for this function:

Definition at line 361 of file test_WorkflowTool.py.

00361 
00362     def test_notifyBefore( self ):
00363 
00364         provideHandler(notifyBeforeHandler)
00365 
00366         tool = self._makeWithTypesAndChain()
00367 
00368         ob = DummyContent( 'dummy' )
00369         tool.notifyBefore( ob, 'action' )
00370 
00371         for wf in tool.a, tool.b:
00372             notified = wf.notified( 'before' )
00373             self.assertEqual( len( notified ), 1 )
00374             self.assertEqual( notified[0], ( ob, 'action' ) )
00375 
00376             notified = wf.notified( 'before-evt' )
00377             self.assertEqual( len( notified ), 1 )
00378             self.assertEqual( notified[0], ( ob, 'action' ) )

Here is the call graph for this function:

Definition at line 349 of file test_WorkflowTool.py.

00349 
00350     def test_notifyCreated( self ):
00351 
00352         tool = self._makeWithTypesAndChain()
00353 
00354         ob = DummyContent( 'dummy' )
00355         tool.notifyCreated( ob )
00356 
00357         for wf in tool.a, tool.b:
00358             notified = wf.notified( 'created' )
00359             self.assertEqual( len( notified ), 1 )
00360             self.assertEqual( notified[0], ( ob, ) )

Here is the call graph for this function:

Definition at line 397 of file test_WorkflowTool.py.

00397 
00398     def test_notifyException( self ):
00399 
00400         provideHandler(notifyExceptionHandler)
00401 
00402         tool = self._makeWithTypesAndChain()
00403 
00404         ob = DummyContent( 'dummy' )
00405         tool.notifyException( ob, 'action', 'exception' )
00406 
00407         for wf in tool.a, tool.b:
00408             notified = wf.notified( 'exception' )
00409             self.assertEqual( len( notified ), 1 )
00410             self.assertEqual( notified[0], ( ob, 'action', 'exception' ) )
00411 
00412             notified = wf.notified( 'exception-evt' )
00413             self.assertEqual( len( notified ), 1 )
00414             self.assertEqual( notified[0], ( ob, 'action', 'exception' ) )

Here is the call graph for this function:

Definition at line 379 of file test_WorkflowTool.py.

00379 
00380     def test_notifySuccess( self ):
00381 
00382         provideHandler(notifySuccessHandler)
00383 
00384         tool = self._makeWithTypesAndChain()
00385 
00386         ob = DummyContent( 'dummy' )
00387         tool.notifySuccess( ob, 'action' )
00388 
00389         for wf in tool.a, tool.b:
00390             notified = wf.notified( 'success' )
00391             self.assertEqual( len( notified ), 1 )
00392             self.assertEqual( notified[0], ( ob, 'action', None ) )
00393 
00394             notified = wf.notified( 'success-evt' )
00395             self.assertEqual( len( notified ), 1 )
00396             self.assertEqual( notified[0], ( ob, 'action', None ) )

Here is the call graph for this function:

Definition at line 252 of file test_WorkflowTool.py.

00252 
00253     def test_notReallyContent( self ):
00254 
00255         tool = self._makeWithTypesAndChain()
00256         dummy = DummyNotReallyContent( 'doh' )
00257         self.assertEquals( len( tool.getDefaultChainFor( dummy ) ), 0 )
00258         self.assertEquals( len( tool.getDefaultChain() ), 1 )
00259         self.assertEquals( len( tool.listChainOverrides() ), 1 )
00260         self.assertEquals( len( tool.getChainFor( dummy ) ), 0 )
00261         self.assertEquals( len( tool.getCatalogVariablesFor( dummy ) ), 0 )

Here is the call graph for this function:

Definition at line 292 of file test_WorkflowTool.py.

00292 
00293     def test_setChainForPortalTypes(self):
00294 
00295         tool = self._makeWithTypes()
00296         tool.setDefaultChain('b, a')
00297         dummy = DummyContent('dummy')
00298 
00299         tool.setChainForPortalTypes( ('Dummy Content',), ('a', 'b') )
00300         self.assertEquals( tool.getChainFor(dummy), ('a', 'b') )
00301         tool.setChainForPortalTypes( ('Dummy Content',), 'a, b' )
00302         self.assertEquals( tool.getChainFor(dummy), ('a', 'b') )
00303 
00304         tool.setChainForPortalTypes( ('Dummy Content',), () )
00305         self.assertEquals( tool.getChainFor(dummy), () )
00306         tool.setChainForPortalTypes( ('Dummy Content',), '' )
00307         self.assertEquals( tool.getChainFor(dummy), () )
00308 
00309         tool.setChainForPortalTypes( ('Dummy Content',), None )
00310         self.assertEquals( tool.getChainFor(dummy), ('b', 'a') )
00311 
00312         # Using the '(Default)' keyword
00313         # http://www.zope.org/Collectors/CMF/475
00314         tool.setChainForPortalTypes( ('Dummy Content',), '(Default)' )
00315         self.assertEquals( tool.getChainFor(dummy), () )

Here is the call graph for this function:

Definition at line 189 of file test_WorkflowTool.py.

00189 
00190     def test_z2interfaces(self):
00191         from Interface.Verify import verifyClass
00192         from Products.CMFCore.interfaces.portal_actions \
00193                 import ActionProvider as IActionProvider
00194         from Products.CMFCore.interfaces.portal_workflow \
00195                 import portal_workflow as IWorkflowTool
00196         from Products.CMFCore.WorkflowTool import WorkflowTool
00197 
00198         verifyClass(IActionProvider, WorkflowTool)
00199         verifyClass(IWorkflowTool, WorkflowTool)

Definition at line 200 of file test_WorkflowTool.py.

00200 
00201     def test_z3interfaces(self):
00202         from zope.interface.verify import verifyClass
00203         from Products.CMFCore.interfaces import IActionProvider
00204         from Products.CMFCore.interfaces import IConfigurableWorkflowTool
00205         from Products.CMFCore.interfaces import IWorkflowTool
00206         from Products.CMFCore.WorkflowTool import WorkflowTool
00207 
00208         verifyClass(IActionProvider, WorkflowTool)
00209         verifyClass(IConfigurableWorkflowTool, WorkflowTool)
00210         verifyClass(IWorkflowTool, WorkflowTool)

    Build a tree of objects, invoke tool.updateRoleMappings,
    and then check to see that the workflows each got called;
    check the resulting count, as well.

Definition at line 415 of file test_WorkflowTool.py.

00415 
00416     def xxx_test_updateRoleMappings( self ):
00417         """
00418             Build a tree of objects, invoke tool.updateRoleMappings,
00419             and then check to see that the workflows each got called;
00420             check the resulting count, as well.
00421         """
00422 


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