[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful/tests - test_instance.py:1.8
Stephan Richter
srichter@cosmos.phy.tufts.edu
Wed, 30 Jul 2003 11:24:18 -0400
Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful/tests
In directory cvs.zope.org:/tmp/cvs-serv7446/src/zope/app/workflow/stateful/tests
Modified Files:
test_instance.py
Log Message:
This is a good checkpoint and I am going to check this stuff in...
- Created Workflow events and enhanced some tests to test for them being
published correctly.
- Revived RelevantData and compacted the code. I threw out all of the
checker code for now. I have a feeling that we ain't gotta need it.
The last steps are:
- Being able to specify permissions (set and get) for each field of the
RelevantData Schema.
- View/Modify the RelevantData in a Process Instance.
Once I am done with that, I think that the workflow code is in a good state
for the beta.
=== Zope3/src/zope/app/workflow/stateful/tests/test_instance.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/workflow/stateful/tests/test_instance.py:1.7 Sat Jun 21 17:22:17 2003
+++ Zope3/src/zope/app/workflow/stateful/tests/test_instance.py Wed Jul 30 11:24:12 2003
@@ -11,9 +11,8 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Process Difinition Instance Tests
-Revision information:
$Id$
"""
@@ -24,6 +23,8 @@
from zope.schema import Text, Int
from zope.component.service import serviceManager
+from zope.app.event.tests.placelesssetup import \
+ eventPublisher, EventRecorder, events, clearEvents
from zope.app.interfaces.security import IPermissionService
from zope.app.security.registries.permissionregistry \
import permissionRegistry
@@ -42,6 +43,11 @@
from zope.app.workflow.service import ProcessDefinitionRegistration
from zope.app.interfaces.workflow.stateful \
import IStatefulProcessInstance
+from zope.app.interfaces.workflow.stateful import \
+ IBeforeTransitionEvent, IAfterTransitionEvent
+from zope.app.interfaces.workflow.stateful import IRelevantDataChangeEvent
+from zope.app.interfaces.workflow.stateful import \
+ IBeforeRelevantDataChangeEvent, IAfterRelevantDataChangeEvent
from zope.app.workflow.stateful.definition \
import StatefulProcessDefinition, State, Transition
from zope.app.workflow.stateful.instance \
@@ -107,6 +113,10 @@
self.pi = ContextWrapper(
self.service.createProcessInstance('definition1'),
self.rootFolder)
+ # Let's also listen to the fired events
+ clearEvents()
+ eventPublisher.globalSubscribe(EventRecorder)
+
def testInterface(self):
verifyClass(IStatefulProcessInstance, StatefulProcessInstance)
@@ -121,7 +131,12 @@
self.assertEqual(data.value, 1)
data.text = 'another text'
+ self.assert_(IBeforeRelevantDataChangeEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterRelevantDataChangeEvent.isImplementedBy(events[-1]))
+ clearEvents()
data.value = 10
+ self.assert_(IBeforeRelevantDataChangeEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterRelevantDataChangeEvent.isImplementedBy(events[-1]))
self.assertEqual(data.text, 'another text')
self.assertEqual(data.value, 10)
@@ -133,28 +148,46 @@
self.assertEqual(pi.status, pd.getInitialStateName())
self.assertEqual(pi.getOutgoingTransitions(), ['show'])
+ clearEvents()
pi.fireTransition('show')
+ self.assert_(IBeforeTransitionEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterTransitionEvent.isImplementedBy(events[-1]))
self.assertEqual(pi.status, 'private')
self.assertEqual(sort(pi.getOutgoingTransitions()),
['publish_direct', 'submit_pending'])
+ clearEvents()
pi.fireTransition('submit_pending')
+ self.assert_(IBeforeTransitionEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterTransitionEvent.isImplementedBy(events[-1]))
self.assertEqual(pi.status, 'pending')
self.assertEqual(sort(pi.getOutgoingTransitions()),
['publish_pending', 'retract_pending'])
+ clearEvents()
pi.fireTransition('publish_pending')
+ self.assert_(IBeforeTransitionEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterTransitionEvent.isImplementedBy(events[-1]))
self.assertEqual(pi.status, 'published')
self.assertEqual(sort(pi.getOutgoingTransitions()),
['retract_published'])
+ clearEvents()
pi.fireTransition('retract_published')
+ self.assert_(IBeforeTransitionEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterTransitionEvent.isImplementedBy(events[-1]))
self.assertEqual(pi.status, 'private')
+ clearEvents()
pi.fireTransition('submit_pending')
+ self.assert_(IBeforeTransitionEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterTransitionEvent.isImplementedBy(events[-1]))
self.assertEqual(pi.status, 'pending')
+ clearEvents()
pi.fireTransition('retract_pending')
+ self.assert_(IBeforeTransitionEvent.isImplementedBy(events[0]))
+ self.assert_(IAfterTransitionEvent.isImplementedBy(events[-1]))
self.assertEqual(pi.status, 'private')