class countWorkitemsTestCase(unittest.TestCase): def setUp(self): # Create an OpenFlow folder self.of = CMFOpenflowTool('of') # Create some Process Definition for id in ['first','second','third']: self.of.addProcess(id=id, BeginEnd=1) self.pd = getattr(self.of, id) self.pd.addTransition(id=id, From='Begin', To='End') self.pd['Begin'].edit(kind='Standard') # Routing: 6 workitems # instance with workitem inactive and unassigned pid = self.of.addInstance(id, 'test1', 'testComment', 'TestTitle', 1) # instance with workitem inactive and assigned pid = self.of.addInstance(id, 'test2', 'testComment', 'TestTitle', 1) pid = self.of.assignWorkitem(pid,'0','testUser') # instance with workitem active pid = self.of.addInstance(id, 'test3', 'testComment', 'TestTitle', 1) self.of.activateWorkitem(pid,'0','testUser') # instance with workitem completed pid=self.of.addInstance(id, 'test4', 'testComment', 'TestTitle', 1) self.of.activateWorkitem(pid,'0','testUser') self.of.completeWorkitem(pid,'0') # instance with 2 workitems completed pid=self.of.addInstance(id, 'test5', 'testComment', 'TestTitle', 1) self.of.activateWorkitem(pid,'0','testUser') self.of.completeWorkitem(pid,'0') self.of.forwardWorkitem(pid,'0') def checkCountWorkitems(self): """ Check results of countWorkitems""" assert self.of.countWorkitems()=={'to do':'6', 'to assign':'3', 'completed':'9'},'Result error for process' assert self.of.countWorkitems('first')=={'to do':'2', 'to assign':'1', 'completed':'3'},'Result error for process' assert self.of.countWorkitems('first','Begin')=={'to do':'2', 'to assign':'1', 'completed':'2'},'Result error for process and activity' assert self.of.countWorkitems('first','Begin','testUser')=={'to do':'2', 'to assign':'1', 'completed':'2'},'Result error for process, activity and user'
class routingSimpleTestCase(unittest.TestCase): def setUp(self): # Create an OpenFlow folder self.of = CMFOpenflowTool('of') # Create a Process Definition with two activity (Begin, End) and one transition. self.of.addProcess(id='begin_end', BeginEnd=1) self.pd = getattr(self.of, 'begin_end') self.pd.addTransition(id='begin_end', From='Begin', To='End') getattr(self.pd, 'Begin').edit(kind='standard') getattr(self.pd, 'End').edit(kind='standard') # Create a Process Instance of the Process definition mentioned above pid = self.of.addInstance('begin_end', 'test', 'testComment', 'TestTitle', 0) self.pi = getattr(self.of, pid) def checkCreation(self): """ Check for the correct creation of the test objects """ assert self.of, 'openflow folder not created' assert self.pd, 'process definition not created' assert getattr(self.pd, 'Begin'), 'Begin activity not created' assert getattr(self.pd, 'End'), 'End activity not created' assert getattr(self.pd, 'begin_end'), 'begin_end transition not created' assert self.pi, 'process instance not created' def checkActivateInstance(self): """ Check the Process Instance activation """ assert self.pi.status == 'initiated', 'process instance starting status not correct' self.of.startInstance(self.pi.id) assert self.pi.status == 'running', 'process instance activation not correct' def checkSuspendInstance(self): """ Check the Process Instance activation """ assert self.pi.status == 'initiated', 'process instance starting status not correct' self.of.suspendInstance(self.pi.id) assert self.pi.status == 'suspended', 'process instance suspension not correct' def checkResumeInstance(self): """ Check the Process Instance activation """ assert self.pi.status == 'initiated', 'process instance starting status not correct' self.of.suspendInstance(self.pi.id) assert self.pi.status == 'suspended', 'process instance suspension not correct' self.of.resumeInstance(self.pi.id) assert self.pi.status == 'initiated', 'process instance suspension not correct' def checkTerminationInstance(self): """ Check the Process Instance activation """ assert self.pi.status == 'initiated', 'process instance starting status not correct' self.of.terminateInstance(self.pi.id) assert self.pi.status == 'terminated', 'process instance suspension not correct' def checkAssignUnassignedWorkitem(self): """ Check the workitem creation and activation """ self.of.startInstance(self.pi.id) self.w = getattr(self.pi, '0') assert self.w.status == 'inactive', 'workitem creation not correct' self.of.assignWorkitem(self.pi.id, self.w.id, 'testActor') assert self.w.actor == 'testActor', 'workitem assignement not correct' self.of.unassignWorkitem(self.pi.id, self.w.id) assert self.w.actor == '', 'workitem unassignement not correct' def checkActivateWorkitem(self): """ Check the workitem creation and activation """ self.of.startInstance(self.pi.id) self.w = getattr(self.pi, '0') assert self.w.status == 'inactive', 'workitem creation not correct' self.of.activateWorkitem(self.pi.id, self.w.id) assert self.w.status == 'active', 'workitem activation not correct' def checkInactivateWorkitem(self): """ Check the workitem inactivation """ self.of.startInstance(self.pi.id) self.w = getattr(self.pi, '0') assert self.w.status == 'inactive', 'workitem creation not correct' self.of.activateWorkitem(self.pi.id, self.w.id) assert self.w.status == 'active', 'workitem activation not correct' self.of.inactivateWorkitem(self.pi.id, self.w.id) assert self.w.status == 'inactive', 'workitem inactivation not correct' def checkSuspendWorkitem(self): """ Check the workitem suspended """ self.of.startInstance(self.pi.id) self.w = getattr(self.pi, '0') assert self.w.status == 'inactive', 'workitem creation not correct' self.of.suspendWorkitem(self.pi.id, self.w.id) assert self.w.status == 'suspended', 'workitem suspension not correct' def checkResumeWorkitem(self): """ Check the workitem resume """ self.of.startInstance(self.pi.id) self.w = getattr(self.pi, '0') assert self.w.status == 'inactive', 'workitem creation not correct' self.of.suspendWorkitem(self.pi.id, self.w.id) assert self.w.status == 'suspended', 'workitem suspension not correct' self.of.resumeWorkitem(self.pi.id, self.w.id) assert self.w.status == 'inactive', 'workitem inactivation not correct' def checkCompleteWorkitem(self): """ Check the workitem completion """ self.of.startInstance(self.pi.id) self.w = getattr(self.pi, '0') self.of.activateWorkitem(self.pi.id, self.w.id) self.of.completeWorkitem(self.pi.id, self.w.id) assert self.w.status == 'complete', 'workitem completion not correct' def checkForwardWorkitem(self): """ Check the workitem forwarding """ self.of.startInstance(self.pi.id) self.w0 = getattr(self.pi, '0') self.of.activateWorkitem(self.pi.id, self.w0.id) self.of.completeWorkitem(self.pi.id, self.w0.id) self.of.forwardWorkitem(self.pi.id, self.w0.id) assert getattr(self.pi, '1'), 'new workitem not created' assert getattr(self.pi, '1').status == 'inactive', 'new workitem status not correct' def checkCompleteInstance(self): """ Check the process instance completion """ self.of.startInstance(self.pi.id) self.w0 = getattr(self.pi, '0') self.of.activateWorkitem(self.pi.id, self.w0.id) self.of.completeWorkitem(self.pi.id, self.w0.id) self.of.forwardWorkitem(self.pi.id, self.w0.id) self.w1 = getattr(self.pi, '1') self.of.activateWorkitem(self.pi.id, self.w1.id) self.of.completeWorkitem(self.pi.id, self.w1.id) assert self.w0.status == 'complete', 'first workitem completion not correct' assert self.w1.status == 'complete', 'last workitem completion not correct' assert self.pi.status == 'complete', 'process instance completion not correct'