[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Workflow/tests - testWorkflowWorkitem.py:1.1.2.1
Florent Guillaume
fg@nuxeo.com
Tue, 5 Mar 2002 13:43:06 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Workflow/tests
In directory cvs.zope.org:/tmp/cvs-serv23577/tests
Added Files:
Tag: Zope-3x-branch
testWorkflowWorkitem.py
Log Message:
tres+florent: Initial cut of workflow items.
=== Added File Zope3/lib/python/Zope/App/Workflow/tests/testWorkflowWorkitem.py ===
import unittest
from Interface import verify
class WorkflowWorkitemTests(unittest.TestCase):
def testInterface(self):
from Zope.App.Workflow.IWorkflowWorkitem import IWorkflowWorkitem
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem
verify(IWorkflowWorkitem, WorkflowWorkitem)
def _getOne(self, *args, **kw):
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem
return WorkflowWorkitem(*args, **kw)
def testGetProcessInstance(self):
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem
pi = []
wi = self._getOne(pi)
npi = wi.getProcessInstance()
self.assertEqual(pi, npi)
def testEmpty(self):
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem, INIT
pi = []
wi = self._getOne(pi)
assignee = wi.getAssignee()
state = wi.getState()
self.assertEqual(assignee, None)
self.assertEqual(state, INIT)
def testAssignee(self):
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem
pi = []
wi = self._getOne(pi)
assignee = []
wi.assign(assignee)
nassignee = wi.getAssignee()
self.assertEqual(assignee, nassignee)
def testBegin(self):
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem, \
WorkflowWorkitemException, BEGUN
pi = []
wi = self._getOne(pi)
wi.begin()
state = wi.getState()
self.assertEqual(state, BEGUN)
self.assertRaises(WorkflowWorkitemException, wi.begin)
def testComplete(self):
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem, \
WorkflowWorkitemException, COMPLETED
pi = []
wi = self._getOne(pi)
self.assertRaises(WorkflowWorkitemException, wi.complete)
self.assertRaises(WorkflowWorkitemException, wi.fail)
wi.begin()
wi.complete()
state = wi.getState()
self.assertEqual(state, COMPLETED)
self.assertRaises(WorkflowWorkitemException, wi.begin)
self.assertRaises(WorkflowWorkitemException, wi.complete)
self.assertRaises(WorkflowWorkitemException, wi.fail)
def testFail(self):
from Zope.App.Workflow.WorkflowWorkitem import WorkflowWorkitem, \
WorkflowWorkitemException, FAILED
pi = []
wi = self._getOne(pi)
self.assertRaises(WorkflowWorkitemException, wi.complete)
self.assertRaises(WorkflowWorkitemException, wi.fail)
wi.begin()
wi.fail()
state = wi.getState()
self.assertEqual(state, FAILED)
self.assertRaises(WorkflowWorkitemException, wi.begin)
self.assertRaises(WorkflowWorkitemException, wi.complete)
self.assertRaises(WorkflowWorkitemException, wi.fail)
if __name__ == '__main__':
unittest.main()