Commit 4bcaf09e authored by iv's avatar iv

ERP5Workflow: improve permission test on workflow states

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