[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful/tests - test_instance.py:1.4
Steve Alexander
steve@cat-box.net
Tue, 3 Jun 2003 10:34:04 -0400
Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful/tests
In directory cvs.zope.org:/tmp/cvs-serv30268/src/zope/app/workflow/stateful/tests
Modified Files:
test_instance.py
Log Message:
improvements to formatting, implements(), and removed unneeded import
=== Zope3/src/zope/app/workflow/stateful/tests/test_instance.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/workflow/stateful/tests/test_instance.py:1.3 Sun Jun 1 11:59:39 2003
+++ Zope3/src/zope/app/workflow/stateful/tests/test_instance.py Tue Jun 3 10:34:04 2003
@@ -19,7 +19,7 @@
import unittest
-from zope.interface import Interface
+from zope.interface import Interface, implements
from zope.interface.verify import verifyClass
from zope.schema import Text, Int
@@ -35,10 +35,7 @@
from zope.app.context import ContextWrapper
from zope.app.traversing import traverse
-from zope.app.container.zopecontainer import ZopeContainerAdapter
-
-from zope.app.interfaces.services.configuration \
- import IUseConfigurable
+from zope.app.interfaces.services.configuration import IUseConfigurable
from zope.app.interfaces.annotation import IAttributeAnnotatable
from zope.app.interfaces.services.configuration \
import Active, Unregistered, Registered
@@ -54,13 +51,9 @@
import StatefulProcessInstance, StateChangeInfo
-
-
# define and create ProcessDefinition (PD) for tests
class TestProcessDefinition(StatefulProcessDefinition):
- __implements__ = IAttributeAnnotatable, IUseConfigurable, \
- StatefulProcessDefinition.__implements__
-
+ implements(IAttributeAnnotatable, IUseConfigurable)
class ITestDataSchema(Interface):
@@ -75,7 +68,6 @@
return l
-
class SimpleProcessInstanceTests(WorkflowSetup, unittest.TestCase):
def setUp(self):
@@ -88,7 +80,7 @@
pd.states.setObject('private', State())
pd.states.setObject('published', State())
pd.states.setObject('pending', State())
-
+
pd.transitions.setObject('show',
Transition('INITIAL', 'private'))
pd.transitions.setObject('publish_direct',
@@ -114,11 +106,9 @@
self.service.createProcessInstance('definition1'),
self.rootFolder)
-
def testInterface(self):
verifyClass(IStatefulProcessInstance, StatefulProcessInstance)
-
def testRelevantData(self):
pi = self.pi
data = pi.data
@@ -133,15 +123,14 @@
self.assertEqual(data.text, 'another text')
self.assertEqual(data.value, 10)
-
def testSimpleTranstitions(self):
pi = self.pi
pd = self.pd
-
+
self.assertEqual(pi.status, pd.getInitialStateName())
self.assertEqual(pi.getOutgoingTransitions(), ['show'])
-
+
pi.fireTransition('show')
self.assertEqual(pi.status, 'private')
self.assertEqual(sort(pi.getOutgoingTransitions()),
@@ -167,9 +156,6 @@
self.assertEqual(pi.status, 'private')
-
-
-
class ConditionProcessInstanceTests(WorkflowSetup, unittest.TestCase):
def setUp(self):
@@ -181,7 +167,7 @@
pd.states.setObject('state1', State())
pd.states.setObject('state2', State())
-
+
pd.transitions.setObject('initial_state1',
Transition('INITIAL', 'state1',
condition='data/value'))
@@ -213,14 +199,12 @@
self.service.createProcessInstance('definition1'),
self.rootFolder)
-
-
def testConditionalTranstitions(self):
pi = self.pi
pd = self.pd
data = pi.data
-
+
self.assertEqual(pi.status, pd.getInitialStateName())
self.assertEqual(data.text, 'no text')
self.assertEqual(data.value, 1)
@@ -233,7 +217,7 @@
self.assertEqual(pi.getOutgoingTransitions(), ['state1_initial'])
data.text = 'some text'
-
+
self.assertEqual(sort(pi.getOutgoingTransitions()),
['state1_initial', 'state1_state2'])
@@ -251,17 +235,13 @@
data.value = 0
self.assertEqual(pi.getOutgoingTransitions(), ['initial_state2'])
-
+
pi.fireTransition('initial_state2')
self.assertEqual(pi.status, 'state2')
self.assertEqual(pi.getOutgoingTransitions(),
['state2_initial', 'state2_state1'])
-
-
-
-
def transition_script1(contexts):
return contexts['data'].text == "some text"
@@ -279,7 +259,7 @@
pd.states.setObject('state1', State())
pd.states.setObject('state2', State())
-
+
pd.transitions.setObject('initial_state1',
Transition('INITIAL', 'state1',
script=lambda c: c['data'].value))
@@ -310,14 +290,12 @@
self.service.createProcessInstance('definition1'),
self.rootFolder)
-
-
def testConditionalTranstitions(self):
pi = self.pi
pd = self.pd
data = pi.data
-
+
self.assertEqual(pi.status, pd.getInitialStateName())
self.assertEqual(data.text, 'no text')
self.assertEqual(data.value, 1)
@@ -330,7 +308,7 @@
self.assertEqual(pi.getOutgoingTransitions(), ['state1_initial'])
data.text = 'some text'
-
+
self.assertEqual(sort(pi.getOutgoingTransitions()),
['state1_initial', 'state1_state2'])
@@ -348,15 +326,13 @@
data.value = 0
self.assertEqual(pi.getOutgoingTransitions(), ['initial_state2'])
-
+
pi.fireTransition('initial_state2')
self.assertEqual(pi.status, 'state2')
self.assertEqual(pi.getOutgoingTransitions(),
['state2_initial', 'state2_state1'])
-
-
class PermissionProcessInstanceTests(WorkflowSetup, unittest.TestCase):
def setUp(self):
@@ -375,7 +351,7 @@
pd.states.setObject('state1', State())
pd.states.setObject('state2', State())
-
+
pd.transitions.setObject('initial_state1',
Transition('INITIAL', 'state1',
permission=CheckerPublic))
@@ -406,8 +382,6 @@
self.service.createProcessInstance('definition1'),
self.rootFolder)
-
-
def testPermissionedTranstitions(self):
pi = self.pi
pd = self.pd
@@ -422,7 +396,6 @@
self.assertEqual(pi.getOutgoingTransitions(), ['state1_state2'])
-
class DummyTransition:
def __init__(self, source, destination):
self.sourceState = source
@@ -436,9 +409,6 @@
sci = StateChangeInfo(t)
self.assertEqual(sci.old_state, 1)
self.assertEqual(sci.new_state, 2)
-
-
-
def test_suite():