Commit 4bcaf09e authored by iv's avatar iv

ERP5Workflow: improve permission test on workflow states

parent 8611120f
......@@ -221,7 +221,6 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
"""
portal_workflow = self.portal.portal_workflow
self.logMessage(" Save portal type original configuration")
text_portal_type = self.portal.portal_types._getOb('Workflow Test Document')
temporary_workflow_id = 'temporary_edit_workflow'
......@@ -233,60 +232,46 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
permission = 'View management screens'
permission_key = '_' + permission.replace(' ', '_') + '_Permission'
self.logMessage(" Create a Workflow Test document: it will have the usual"
+ " permissions defined by edit_workflow")
# create a Workflow Test document: it will have the usual permissions
# defined by edit_workflow
text_document = self.getTestObject()
self.logMessage(" Verify that the permission '" + permission + "' is not " +
"declared on the text document yet")
# Verify that the permission 'View management screens' is not declared on
# the text document yet
self.assertFalse(getattr(text_document, permission_key, False))
workflow = portal_workflow._getOb(temporary_workflow_id)
# XXX(WORFKLOW): remove this code block once merged into erp5 master
if workflow.getPortalType() != 'Workflow':
self.logMessage(" Converting workflow " + temporary_workflow_id)
portal_workflow.WorkflowTool_convertWorkflow(
batch_mode=True,
workflow_id_list=[temporary_workflow_id]
)
self.tic()
workflow = portal_workflow._getOb(temporary_workflow_id)
self.assertEqual(workflow.getPortalType(), 'Workflow')
self.logMessage(" Changing permission list to: %s" % [permission])
workflow.setWorkflowManagedPermissionList([permission])
self.tic()
self.logMessage(" Verify permission roles dict on 'current' state")
# Verify permission roles dict on 'current' state"
permission_roles_dict = workflow.state_current\
.getStatePermissionRolesDict()
self.assertIn(permission, permission_roles_dict)
self.logMessage(" Change roles for '" + permission +
"' on state and update role list for permission")
# change roles and update permission/roles mapping on text_document
# and check document permissions/roles mapping was updated
# it should be a tuple, as there is no acquisition (otherwise a list)
permission_roles_dict[permission] = ['Assignor']
workflow.state_current.setAcquirePermissionList([])
workflow.updateRoleMappingsFor(text_document)
self.tic()
self.logMessage(" Check document permissions/roles mapping was updated "
+ "(it should be a tuple, as there is no acquisition)")
self.assertEqual(getattr(text_document, permission_key), ('Assignor',))
self.logMessage(" Configure acquisition for '" + permission +
"' on state and update role list for permission")
# set acquisition and verify that permission/roles mapping is now a list
workflow.state_current.setAcquirePermissionList([permission])
workflow.updateRoleMappingsFor(text_document)
self.tic()
self.logMessage(" Check document permissions/roles mapping is now" +
" a list (acquisition)")
self.assertEqual(getattr(text_document, permission_key), ['Assignor'])
self.logMessage(" Restore original configuration")
portal_workflow.manage_delObjects(temporary_workflow_id)
class TestDCWorkflow(TestERP5WorkflowMixin):
"""
Check DC Workflow works correctly in new Workflow Tool.
......
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