Commit 4d78759b authored by iv's avatar iv

ERP5Workflow: fix test by using guard_ prefix (see new Guard property sheet) +

fix Workflow creation/removal
parent 0985c2ef
......@@ -49,6 +49,8 @@ class TestWorklist(testWorkflowMixin):
self.createERP5Users()
self.clearCache()
self.tic()
self.removeWorklist('validation_workflow', self.test_worklist_dict.keys())
self.tic()
def beforeTearDown(self):
self.cleanUp()
......@@ -126,6 +128,8 @@ class TestWorklist(testWorkflowMixin):
if workflow_value.__class__.__name__ == 'Workflow':
if getattr(workflow_value, worklist_id, None):
workflow_value.manage_delObjects([worklist_id])
worklist_value = getattr(workflow_value, 'worklist_%s' % worklist_id, None)
if worklist_value is None:
worklist_value = workflow_value.newContent(portal_type='Worklist')
guard_roles = [] if not guard_roles else [role.strip() for role in guard_roles.split(';')]
# XXX(WORKFLOW), it would be much nicer to use categories instead of ids like 'state_draft',
......@@ -139,8 +143,8 @@ class TestWorklist(testWorkflowMixin):
actbox_category='global',
matched_validation_state=validation_state,
matched_portal_type_list=portal_type,
role_list=guard_roles,
expression=guard_expr
guard_role_list=guard_roles,
guard_expression=guard_expr
)
for worklist_variable_key, worklist_variable_value in kw.iteritems():
......@@ -168,7 +172,10 @@ class TestWorklist(testWorkflowMixin):
workflow_value = self.getWorkflowTool()[workflow_id]
if workflow_value.__class__.__name__ == 'Workflow':
for worklist_id in worklist_id_list:
try:
workflow_value._delObject('worklist_'+worklist_id)
except KeyError:
pass
else:
worklists = self.getWorkflowTool()[workflow_id].worklists
worklists.deleteWorklists(worklist_id_list)
......@@ -212,7 +219,6 @@ class TestWorklist(testWorkflowMixin):
try:
self.logMessage("Create document as Manager")
document = self.createDocument()
self.tic()
self.clearCache()
......@@ -221,9 +227,9 @@ class TestWorklist(testWorkflowMixin):
self.login(user_id)
result = workflow_tool.listActions(object=document)
self.logMessage("Check %s worklist as Assignor" % user_id)
self.logMessage("Check Assignor worklist as %s" % user_id)
self.checkWorklist(result, 'assignor_todo', 0)
self.logMessage("Check %s worklist as Owner" % user_id)
self.logMessage("Check Owner worklist as %s" % user_id)
self.checkWorklist(result, 'owner_todo', 1)
for user_id in ('foo', 'bar'):
self.logMessage("Check %s worklist" % user_id)
......@@ -246,11 +252,11 @@ class TestWorklist(testWorkflowMixin):
('foo' , 1, 0, 1)):
self.login(user_id)
result = workflow_tool.listActions(object=document)
self.logMessage(" Check %s worklist as Assignor" % user_id)
self.logMessage(" Check Assignor worklist as %s" % user_id)
self.checkWorklist(result, 'assignor_todo', assignor)
self.logMessage(" Check %s worklist as Owner" % user_id)
self.logMessage(" Check Owner worklist as %s" % user_id)
self.checkWorklist(result, 'owner_todo', owner)
self.logMessage(" Check %s worklist as Owner and Assignor" % user_id)
self.logMessage(" Check Owner and Assignor worklist as %s" % user_id)
self.checkWorklist(result, 'assignor_owner_todo', both)
# Check if int variable are managed by the worklist
......@@ -324,7 +330,6 @@ class TestWorklist(testWorkflowMixin):
current_sql_catalog_local_role_keys
self.commit()
finally:
self.removeWorklist('validation_workflow', self.test_worklist_dict.keys())
self.commit()
def test_02_related_key(self, quiet=0, run=run_all_test):
......
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