Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
DCWorkflow.tests.test_DCWorkflow.DCWorkflowDefinitionTests Class Reference

List of all members.

Public Member Functions

def setUp
def test_z2interfaces
def test_z3interfaces
def test_doActionFor
def test_events
def test_checkTransitionGuard
def test_isActionSupported

Public Attributes

 site

Static Public Attributes

 layer = TraversingEventZCMLLayer

Private Member Functions

def _constructDummyWorkflow
def _getDummyWorkflow

Detailed Description

Definition at line 33 of file test_DCWorkflow.py.


Member Function Documentation

Definition at line 58 of file test_DCWorkflow.py.

00058 
00059     def _constructDummyWorkflow(self):
00060         from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
00061 
00062         wftool = self.site.portal_workflow
00063         wftool._setObject('wf', DCWorkflowDefinition('wf'))
00064         wftool.setDefaultChain('wf')
00065         wf = wftool.wf
00066 
00067         wf.states.addState('private')
00068         sdef = wf.states['private']
00069         sdef.setProperties( transitions=('publish',) )
00070 
00071         wf.states.addState('published')
00072         wf.states.setInitialState('private')
00073 
00074         wf.transitions.addTransition('publish')
00075         tdef = wf.transitions['publish']
00076         tdef.setProperties(title='', new_state_id='published', actbox_name='')
00077 
00078         wf.variables.addVariable('comments')
00079         vdef = wf.variables['comments']
00080         vdef.setProperties(description='',
00081                  default_expr="python:state_change.kwargs.get('comment', '')",
00082                  for_status=1, update_always=1)

Definition at line 83 of file test_DCWorkflow.py.

00083 
00084     def _getDummyWorkflow(self):
00085         wftool = self.site.portal_workflow
00086         return wftool.wf

Here is the caller graph for this function:

Definition at line 37 of file test_DCWorkflow.py.

00037 
00038     def setUp(self):
00039         self.site = DummySite('site')
00040         self.site._setObject( 'portal_types', DummyTool() )
00041         self.site._setObject( 'portal_workflow', WorkflowTool() )
00042         self._constructDummyWorkflow()

Definition at line 161 of file test_DCWorkflow.py.

00161 
00162     def test_checkTransitionGuard(self):
00163 
00164         wftool = self.site.portal_workflow
00165         wf = self._getDummyWorkflow()
00166         dummy = self.site._setObject( 'dummy', DummyContent() )
00167         wftool.notifyCreated(dummy)
00168         self.assertEqual( wf._getStatusOf(dummy),
00169                           {'state': 'private', 'comments': ''} )
00170 
00171         # Check
00172         self.assert_(wf._checkTransitionGuard(wf.transitions['publish'],
00173                                               dummy))
00174 
00175         # Check with kwargs propagation
00176         self.assert_(wf._checkTransitionGuard(wf.transitions['publish'],
00177                                               dummy, arg1=1, arg2=2))

Here is the call graph for this function:

Definition at line 87 of file test_DCWorkflow.py.

00087 
00088     def test_doActionFor(self):
00089 
00090         wftool = self.site.portal_workflow
00091         wf = self._getDummyWorkflow()
00092 
00093         dummy = self.site._setObject( 'dummy', DummyContent() )
00094         wftool.notifyCreated(dummy)
00095         self.assertEqual( wf._getStatusOf(dummy),
00096                           {'state': 'private', 'comments': ''} )
00097         wf.doActionFor(dummy, 'publish', comment='foo' )
00098         self.assertEqual( wf._getStatusOf(dummy),
00099                           {'state': 'published', 'comments': 'foo'} )
00100 
00101         # XXX more

Here is the call graph for this function:

Definition at line 102 of file test_DCWorkflow.py.

00102 
00103     def test_events(self):
00104 
00105         events = []
00106 
00107         @adapter(IBeforeTransitionEvent)
00108         def _handleBefore(event):
00109             events.append(event)
00110         provideHandler(_handleBefore)
00111 
00112         @adapter(IAfterTransitionEvent)
00113         def _handleAfter(event):
00114             events.append(event)
00115         provideHandler(_handleAfter)
00116 
00117         wftool = self.site.portal_workflow
00118         wf = self._getDummyWorkflow()
00119 
00120         dummy = self.site._setObject( 'dummy', DummyContent() )
00121         wftool.notifyCreated(dummy)
00122         wf.doActionFor(dummy, 'publish', comment='foo', test='bar')
00123 
00124         self.assertEquals(4, len(events))
00125 
00126         evt = events[0]
00127         self.failUnless(IBeforeTransitionEvent.providedBy(evt))
00128         self.assertEquals(dummy, evt.object)
00129         self.assertEquals('private', evt.old_state.id)
00130         self.assertEquals('private', evt.new_state.id)
00131         self.assertEquals(None, evt.transition)
00132         self.assertEquals({}, evt.status)
00133         self.assertEquals(None, evt.kwargs)
00134 
00135         evt = events[1]
00136         self.failUnless(IAfterTransitionEvent.providedBy(evt))
00137         self.assertEquals(dummy, evt.object)
00138         self.assertEquals('private', evt.old_state.id)
00139         self.assertEquals('private', evt.new_state.id)
00140         self.assertEquals(None, evt.transition)
00141         self.assertEquals({'state': 'private', 'comments': ''}, evt.status)
00142         self.assertEquals(None, evt.kwargs)
00143 
00144         evt = events[2]
00145         self.failUnless(IBeforeTransitionEvent.providedBy(evt))
00146         self.assertEquals(dummy, evt.object)
00147         self.assertEquals('private', evt.old_state.id)
00148         self.assertEquals('published', evt.new_state.id)
00149         self.assertEquals('publish', evt.transition.id)
00150         self.assertEquals({'state': 'private', 'comments': ''}, evt.status)
00151         self.assertEquals({'test' : 'bar', 'comment' : 'foo'}, evt.kwargs)
00152 
00153         evt = events[3]
00154         self.failUnless(IAfterTransitionEvent.providedBy(evt))
00155         self.assertEquals(dummy, evt.object)
00156         self.assertEquals('private', evt.old_state.id)
00157         self.assertEquals('published', evt.new_state.id)
00158         self.assertEquals('publish', evt.transition.id)
00159         self.assertEquals({'state': 'published', 'comments': 'foo'}, evt.status)
00160         self.assertEquals({'test' : 'bar', 'comment' : 'foo'}, evt.kwargs)

Here is the call graph for this function:

Definition at line 178 of file test_DCWorkflow.py.

00178 
00179     def test_isActionSupported(self):
00180 
00181         wf = self._getDummyWorkflow()
00182         dummy = self.site._setObject( 'dummy', DummyContent() )
00183 
00184         # check publish
00185         self.assert_(wf.isActionSupported(dummy, 'publish'))
00186 
00187         # Check with kwargs.
00188         self.assert_(wf.isActionSupported(dummy, 'publish', arg1=1, arg2=2))

Here is the call graph for this function:

Definition at line 43 of file test_DCWorkflow.py.

00043 
00044     def test_z2interfaces(self):
00045         from Interface.Verify import verifyClass
00046         from Products.CMFCore.interfaces.portal_workflow \
00047              import WorkflowDefinition as IWorkflowDefinition
00048         from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
00049 
00050         verifyClass(IWorkflowDefinition, DCWorkflowDefinition)

Definition at line 51 of file test_DCWorkflow.py.

00051 
00052     def test_z3interfaces(self):
00053         from zope.interface.verify import verifyClass
00054         from Products.CMFCore.interfaces import IWorkflowDefinition
00055         from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
00056 
00057         verifyClass(IWorkflowDefinition, DCWorkflowDefinition)


Member Data Documentation

Definition at line 35 of file test_DCWorkflow.py.

Definition at line 38 of file test_DCWorkflow.py.


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