Commit 1b86759a authored by iv's avatar iv

ERP5Workflow: add test on Guards used in Interaction and Transition

parent f5daca6b
......@@ -176,14 +176,11 @@ class TestERP5Workflow(ERP5TypeTestCase):
# restrictive
def test_beforeScript(self):
workflow = self.workflow_module.newContent(
portal_type='Workflow')
workflow = self.workflow_module.newContent(portal_type='Workflow')
workflow.setReference('wf')
workflow.setStateVariable('current_state')
s1 = workflow.newContent(portal_type='State',
title='State 1')
s2 = workflow.newContent(portal_type='State',
title='State 2')
s1 = workflow.newContent(portal_type='State', title='State 1')
s2 = workflow.newContent(portal_type='State', title='State 2')
s1.setReference('s1')
s2.setReference('s2')
t1 = workflow.newContent(portal_type='Transition', title='Transition 1')
......@@ -207,6 +204,35 @@ class TestERP5Workflow(ERP5TypeTestCase):
# FIXME: not passing parameter to an before script is probably too
# restrictive
def test_TransitionGuards(self, transition_type='Transition'):
workflow_type = 'Workflow' if transition_type == 'Transition' else \
'Interaction Workflow'
workflow = self.workflow_module.newContent(portal_type=workflow_type)
transition = workflow.newContent(portal_type=transition_type)
# roles
transition.setGuardRoleList([])
self.assertEqual([], transition.guard.roles)
transition.setGuardRoleList(['Assignor', 'Assignee'])
self.assertEqual(['Assignor', 'Assignee'], transition.guard.roles)
# permissions
transition.setGuardPermissionList([])
self.assertEqual([], transition.guard.permissions)
transition.setGuardPermissionList(['Modify portal content'])
self.assertEqual(['Modify portal content'], transition.guard.permissions)
# groups
transition.setGuardGroupList([])
self.assertEqual([], transition.guard.groups)
transition.setGuardGroupList(['Group1', 'Group2'])
self.assertEqual(['Group1', 'Group2'], transition.guard.groups)
# expression
transition.setGuardExpression('')
self.assertEqual(None, transition.guard.expr)
transition.setGuardExpression('python: "Hello, world"')
self.assertEqual(transition.guard.expr.text, 'python: "Hello, world"')
def test_InteractionGuards(self):
self.test_TransitionGuards(transition_type='Interaction')
def test_WorkflowSecurity(self):
"""
Test workflow security. Should be test with other methods. To be finished.
......
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