[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Workflow/Stateful/tests - testStatefulProcessDefinition.py:1.1.2.2
Grégoire Weber
zope@i-con.ch
Fri, 6 Dec 2002 09:05:18 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Workflow/Stateful/tests
In directory cvs.zope.org:/tmp/cvs-serv27757/tests
Modified Files:
Tag: sprintathon-wf-branch
testStatefulProcessDefinition.py
Log Message:
added initial unittest
=== Zope3/lib/python/Zope/App/Workflow/Stateful/tests/testStatefulProcessDefinition.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/lib/python/Zope/App/Workflow/Stateful/tests/testStatefulProcessDefinition.py:1.1.2.1 Thu Dec 5 11:44:39 2002
+++ Zope3/lib/python/Zope/App/Workflow/Stateful/tests/testStatefulProcessDefinition.py Fri Dec 6 09:05:16 2002
@@ -17,24 +17,109 @@
$Id$
"""
+import types
import unittest
from Interface import Interface
from Interface.Verify import verifyClass
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
from Zope.App.Workflow.Stateful.IStatefulProcessDefinition \
import IStatefulProcessDefinition
-from Zope.App.Workflow.Stateful.StatefulProcessDefinition \
- import StatefulProcessDefinition
+from Zope.App.Workflow.Stateful.BasicStatefulProcessDefinition \
+ import BasicStatefulProcessDefinition
+
+
+class IDummyState(Interface):
+ """A really dummy state"""
+
+class DummyState:
+ __implements__ = IDummyState
+
+
+class IDummyTransition(Interface):
+ """A really dummy transition"""
+
+class DummyTransition:
+ __implements__ = IDummyTransition
-class StatefulProcessDefinitionTests(unittest.TestCase):
+
+class testStatefulProcessDefinition(unittest.TestCase):
def setUp(self):
- pass
+ self.pd = pd = BasicStatefulProcessDefinition()
+ self.doMinimalSetup()
+
+ def doMinimalSetup(self):
+ pd = self.pd
+ self.st1 = st1 = DummyState()
+ self.st2 = st2 = DummyState()
+ pd.addState('st1', st1)
+ pd.addState('st2', st2)
+
+ self.tr1 = tr1 = DummyTransition()
+ self.tr2 = tr2 = DummyTransition()
+ pd.addTransition('tr1', tr1)
+ pd.addTransition('tr2', tr2)
def testInterface(self):
- verifyClass(IStatefulProcessDefinition, StatefulProcessDefinition)
+ verifyClass(IStatefulProcessDefinition, BasicStatefulProcessDefinition)
+
+ def testGetStateNames(self):
+ pd = self.pd
+
+ names = pd.getStateNames()
+
+ self.failUnless('st1' in names)
+ self.failUnless('st2' in names)
+ self.failUnless(pd.getInitialStateName() in names)
+
+ def testGetState(self):
+ pd = self.pd
+ st1 = pd.getState('st1')
+
+ self.assertEqual(st1, self.st1)
+
+ def testRemoveState(self):
+ pd = self.pd
+
+ pd.removeState('st1')
+ names = pd.getStateNames()
+
+ self.assertRaises(KeyError, pd.getState, 'st1')
+ self.failIf('st1' in names)
+ self.failUnless('st2' in names)
+ self.failUnless(pd.getInitialStateName() in names)
+
+ def testGetTransistionNames(self):
+ pd = self.pd
+
+ names = pd.getTransitionNames()
+
+ self.failUnless('tr1' in names)
+ self.failUnless('tr2' in names)
+
+ def testGetTransation(self):
+ pd = self.pd
+
+ tr1 = pd.getTransition('tr1')
+
+ self.assertEqual(tr1, self.tr1)
+
+ def testRemoveTransistion(self):
+ pd = self.pd
+
+ pd.removeTransition('tr1')
+ names = pd.getTransitionNames()
+
+ self.assertRaises(KeyError, pd.getTransition, 'tr1')
+ self.failIf('tr1' in names)
+ self.failUnless('tr2' in names)
+
+ def tobedone_testCreateProcessInstance(self):
+ pass
def test_suite():
suite = unittest.TestSuite()