Commit 6f6af0c5 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

test: rewrite erp5_core_test with EPR5 Workflow.

parent ef1cf2b3
...@@ -969,16 +969,20 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -969,16 +969,20 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
dummy_simulation_workflow_id = 'fake_simulation_workflow' dummy_simulation_workflow_id = 'fake_simulation_workflow'
dummy_validation_workflow_id = 'fake_validation_workflow' dummy_validation_workflow_id = 'fake_validation_workflow'
#Assume that erp5_styles workflow Manage permissions with acquired Role by default #Assume that erp5_styles workflow Manage permissions with acquired Role by default
addWorkflowByType(pw, 'erp5_workflow', dummy_simulation_workflow_id) dummy_simulation_workflow = pw.newContent(
addWorkflowByType(pw, 'erp5_workflow', dummy_validation_workflow_id) portal_type='Workflow',
dummy_simulation_workflow = pw[dummy_simulation_workflow_id] reference=dummy_simulation_workflow_id,
dummy_validation_workflow = pw[dummy_validation_workflow_id] )
dummy_validation_workflow.variables.setStateVar('validation_state') dummy_validation_workflow = pw.newContent(
portal_type='Workflow',
reference=dummy_validation_workflow_id,
state_variable='validation_state',
)
organisation_type = portal.portal_types.getTypeInfo(portal_type) organisation_type = portal.portal_types.getTypeInfo(portal_type)
organisation_initial_workflow_list = organisation_type.getTypeWorkflowList() organisation_initial_workflow_list = organisation_type.getTypeWorkflowList()
organisation_type.setTypeWorkflowList([dummy_validation_workflow_id, organisation_type.setTypeWorkflowList([dummy_validation_workflow_id,
dummy_simulation_workflow_id]) dummy_simulation_workflow_id])
permission_list = list(dummy_simulation_workflow.permissions) permission_list = dummy_simulation_workflow.getWorkflowManagedPermissionList()
manager_has_permission = {} manager_has_permission = {}
for permission in permission_list: for permission in permission_list:
manager_has_permission[permission] = ('Manager',) manager_has_permission[permission] = ('Manager',)
...@@ -989,7 +993,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -989,7 +993,7 @@ 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.states.draft.permission_roles) 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
...@@ -999,21 +1003,21 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -999,21 +1003,21 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
for permission in permission_list: for permission in permission_list:
self.assertTrue(user.has_permission(permission, obj)) self.assertTrue(user.has_permission(permission, obj))
#2 Now configure both workflow with same configuration #2 Now configure both workflow with same configuration
dummy_simulation_workflow.states.draft.permission_roles = manager_has_permission.copy() dummy_simulation_workflow['state_draft'].setStatePermissionRoleListDict(manager_has_permission.copy())
dummy_validation_workflow.states.draft.permission_roles = manager_has_permission.copy() dummy_validation_workflow['state_draft'].setStatePermissionRoleListDict(manager_has_permission.copy())
dummy_simulation_workflow.updateRoleMappingsFor(obj) dummy_simulation_workflow.updateRoleMappingsFor(obj)
dummy_validation_workflow.updateRoleMappingsFor(obj) dummy_validation_workflow.updateRoleMappingsFor(obj)
for permission in permission_list: for permission in permission_list:
self.assertTrue(user.has_permission(permission, obj)) self.assertTrue(user.has_permission(permission, obj))
#3 change only dummy_simulation_workflow #3 change only dummy_simulation_workflow
dummy_simulation_workflow.states.draft.permission_roles = manager_has_no_permission.copy() dummy_simulation_workflow['state_draft'].setStatePermissionRoleListDict(manager_has_no_permission.copy())
dummy_simulation_workflow.updateRoleMappingsFor(obj) dummy_simulation_workflow.updateRoleMappingsFor(obj)
for permission in permission_list: for permission in permission_list:
self.assertFalse(user.has_permission(permission, obj)) self.assertFalse(user.has_permission(permission, obj))
#4 enable acquisition for dummy_simulation_workflow #4 enable acquisition for dummy_simulation_workflow
dummy_simulation_workflow.states.draft.permission_roles = None dummy_simulation_workflow['state_draft'].setAcquirePermissionList(permission_list)
dummy_simulation_workflow.updateRoleMappingsFor(obj) dummy_simulation_workflow.updateRoleMappingsFor(obj)
for permission in permission_list: for permission in permission_list:
self.assertTrue(user.has_permission(permission, obj)) self.assertTrue(user.has_permission(permission, obj))
......
...@@ -39,7 +39,6 @@ from urllib import pathname2url ...@@ -39,7 +39,6 @@ from urllib import pathname2url
from Products.ERP5Type.Globals import PersistentMapping from Products.ERP5Type.Globals import PersistentMapping
from Products.ERP5Type.dynamic.lazy_class import ERP5BaseBroken from Products.ERP5Type.dynamic.lazy_class import ERP5BaseBroken
from Products.ERP5Type.tests.utils import LogInterceptor from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.Workflow import addWorkflowByType
import shutil import shutil
import os import os
import random import random
...@@ -1315,8 +1314,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -1315,8 +1314,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
""" """
wf_id = 'geek_workflow' wf_id = 'geek_workflow'
pw = self.getWorkflowTool() pw = self.getWorkflowTool()
addWorkflowByType(pw, WORKFLOW_TYPE, wf_id) workflow = pw.newContent(
workflow = pw._getOb(wf_id, None) portal_type='Workflow',
reference=wf_id,
)
self.tic()
self.assertTrue(workflow is not None) self.assertTrue(workflow is not None)
sequence.edit(workflow_id=workflow.getId()) sequence.edit(workflow_id=workflow.getId())
...@@ -2886,8 +2888,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -2886,8 +2888,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
""" """
wf_id = 'custom_geek_workflow' wf_id = 'custom_geek_workflow'
pw = self.getWorkflowTool() pw = self.getWorkflowTool()
addWorkflowByType(pw, WORKFLOW_TYPE, wf_id) workflow = pw.newContent(
workflow = pw._getOb(wf_id, None) portal_type='Workflow',
reference=wf_id,
)
self.tic()
self.assertTrue(workflow is not None) self.assertTrue(workflow is not None)
sequence.edit(workflow_id=workflow.getId()) sequence.edit(workflow_id=workflow.getId())
......
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