Commit 546b35cc authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! erp5_core_test: add a test for unconfigured Workflow State permissions.

parent e67a0908
Pipeline #34998 failed with stage
in 0 seconds
...@@ -993,7 +993,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -993,7 +993,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
try: try:
self.assertTrue(permission_list) self.assertTrue(permission_list)
self.assertFalse(dummy_simulation_workflow['state_draft'].getStatePermissionRoleListDict())
#1 #1
obj = module.newContent(portal_type=portal_type) obj = module.newContent(portal_type=portal_type)
#No role is defined by default on workflow #No role is defined by default on workflow
......
...@@ -148,7 +148,7 @@ class TestERP5Workflow(ERP5TypeTestCase): ...@@ -148,7 +148,7 @@ class TestERP5Workflow(ERP5TypeTestCase):
self.assertEqual(workflow.getCurrentStatusDict(doc)['variable1'], None) self.assertEqual(workflow.getCurrentStatusDict(doc)['variable1'], None)
def test_WorkflowVariables(self): def test_WorkflowPermissions(self):
workflow = self.workflow_module.newContent( workflow = self.workflow_module.newContent(
portal_type='Workflow', portal_type='Workflow',
) )
......
...@@ -294,10 +294,6 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin): ...@@ -294,10 +294,6 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
workflow.updateRoleMappingsFor(text_document) workflow.updateRoleMappingsFor(text_document)
self.assertEqual(getattr(text_document, permission_key), ['Assignor', 'Auditor']) self.assertEqual(getattr(text_document, permission_key), ['Assignor', 'Auditor'])
# remove permission from the workflow, it should be removed from state
workflow.setWorkflowManagedPermissionList([])
self.assertEqual(workflow.state_current.getAcquirePermissionList(), [])
# check the permissions are saved sorted in a canonical form: sorted and as # check the permissions are saved sorted in a canonical form: sorted and as
# tuple # tuple
workflow.state_current.setPermission(permission, ['Auditor', 'Assignor']) workflow.state_current.setPermission(permission, ['Auditor', 'Assignor'])
...@@ -305,6 +301,10 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin): ...@@ -305,6 +301,10 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
workflow.state_current.getStatePermissionRoleListDict().get(permission), workflow.state_current.getStatePermissionRoleListDict().get(permission),
('Assignor', 'Auditor')) ('Assignor', 'Auditor'))
# remove permission from the workflow, it should be removed from state
workflow.setWorkflowManagedPermissionList([])
self.assertEqual(workflow.state_current.getAcquirePermissionList(), [])
def test_14_multiple_workflow_different_permission_roles(self): def test_14_multiple_workflow_different_permission_roles(self):
workflow1 = self.createERP5Workflow('edit_workflow', 'temporary_workflow1') workflow1 = self.createERP5Workflow('edit_workflow', 'temporary_workflow1')
workflow2 = self.createERP5Workflow('edit_workflow', 'temporary_workflow2') workflow2 = self.createERP5Workflow('edit_workflow', 'temporary_workflow2')
...@@ -395,9 +395,8 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin): ...@@ -395,9 +395,8 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
# create document # create document
text_document1 = self.getTestObject() text_document1 = self.getTestObject()
text_document1_permission = getattr(text_document1, permission_key, None) text_document1_permission = getattr(text_document1, permission_key, None)
self.assertEqual(text_document1_permission,
# self.assertEqual(getattr(text_document1, permission_key), ('Assignor', 'Assignee', 'Auditor', 'Author'))
# ['Assignee', 'Assignor', 'Auditor', 'Author'])
# add the second workflow # add the second workflow
text_portal_type.setTypeWorkflowList(['temporary_dc_workflow1', 'temporary_dc_workflow2']) text_portal_type.setTypeWorkflowList(['temporary_dc_workflow1', 'temporary_dc_workflow2'])
...@@ -405,9 +404,7 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin): ...@@ -405,9 +404,7 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
# create document # create document
text_document2 = self.getTestObject() text_document2 = self.getTestObject()
text_document2_permission = getattr(text_document2, permission_key, None) text_document2_permission = getattr(text_document2, permission_key, None)
self.assertEqual(text_document2_permission, None)
# self.assertEqual(getattr(text_document2, permission_key),
# ['Assignee', 'Assignor', 'Auditor', 'Author'])
# migrate workflows # migrate workflows
self.portal.portal_workflow.WorkflowTool_convertWorkflow( self.portal.portal_workflow.WorkflowTool_convertWorkflow(
...@@ -416,15 +413,21 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin): ...@@ -416,15 +413,21 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
) )
self.tic() self.tic()
# create another document # with only one workflow
text_document3 = self.getTestObject() text_portal_type.setTypeWorkflowList(['temporary_dc_workflow1'])
text_document3_permission = getattr(text_document3, permission_key, None)
print('text_document1_permission: %r' % (text_document1_permission, )) # create document
print('text_document2_permission: %r' % (text_document2_permission, )) text_document1a = self.getTestObject()
print('text_document3_permission: %r' % (text_document3_permission, )) text_document1a_permission = getattr(text_document1a, permission_key, None)
self.assertEqual(tuple(getattr(text_document3, permission_key)), self.assertSameSet(text_document1a_permission, text_document1_permission)
('Assignee', 'Assignor', 'Auditor', 'Author'))
# add the second workflow
text_portal_type.setTypeWorkflowList(['temporary_dc_workflow1', 'temporary_dc_workflow2'])
# create document
text_document2a = self.getTestObject()
text_document2a_permission = getattr(text_document2a, permission_key, None)
self.assertEqual(text_document2a_permission, text_document2_permission)
def test_16_testWorklistViewIsAccessible(self): def test_16_testWorklistViewIsAccessible(self):
# check worklist view is available on workflow # check worklist view is available on workflow
......
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