Commit 88cf60a9 authored by Vincent Pelletier's avatar Vincent Pelletier

Add assertWorkflowTransitionFails, new ERP5 and workflow specific method to...

Add assertWorkflowTransitionFails, new ERP5 and workflow specific method to help factorizing unit test code where a workflow transition is supposed to fail.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13518 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3ea6eda8
......@@ -491,6 +491,24 @@ class ERP5TypeTestCase(PortalTestCase):
self.assertEquals(len(a), len(b), msg)
assertSameSet = failIfDifferentSet
def assertWorkflowTransitionFails(self, object, workflow_id, transition_id, error_message=None):
"""
Check that passing given transition from given workflow on given object
raises ValidationFailed.
Do sanity checks (workflow history length increased by one, simulation
state unchanged).
If error_message is provided, it is asserted to be equal to the last
workflow history error message.
"""
reference_history_length = len(self.workflow_tool.getInfoFor(ob=self.account_incident, name='history', wf_id=workflow_id))
reference_workflow_state = object.getSimulationState()
self.assertRaises(ValidationFailed, self.workflow_tool.doActionFor, self.account_incident, transition_id, wf_id=workflow_id)
workflow_history = self.workflow_tool.getInfoFor(ob=self.account_incident, name='history', wf_id=workflow_id)
self.assertEqual(len(workflow_history), reference_history_length + 1)
if error_message is not None:
self.assertEqual(str(workflow_history[-1]['error_message']), error_message)
self.assertEqual(object.getSimulationState(), reference_workflow_state)
def setupERP5Site( business_template_list=(),
app=None,
portal_name=portal_name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment