Commit 6d47fd7b authored by iv's avatar iv

ERP5Workflow: fix worklist for DCWorkflow

don't try to remove non-existing worklists!
+ use getPortalType instead of __class__.__name__
+ only test guard on ERP5Worklow worklists
parent 81fe3cbb
......@@ -49,7 +49,12 @@ class TestWorklist(testWorkflowMixin):
self.createERP5Users()
self.clearCache()
self.tic()
self.removeWorklist('validation_workflow', self.test_worklist_dict.keys())
worklist_to_remove_list = [ key for key in self.test_worklist_dict.keys()
if getattr(self.getPortalObject().portal_workflow.validation_workflow,
key,
False)
]
self.removeWorklist('validation_workflow', worklist_to_remove_list)
self.tic()
def beforeTearDown(self):
......@@ -107,7 +112,7 @@ class TestWorklist(testWorkflowMixin):
# Add new workflow compatibility
# Will otherwise add dynamic variable in worklist.
workflow_value = self.getWorkflowTool()[workflow_id]
if workflow_value.__class__.__name__ != 'Workflow':
if workflow_value.getPortalType() != 'Workflow':
variables = workflow_value.variables
if not getattr(variables, variable_id, None):
variables.addVariable(variable_id)
......@@ -116,7 +121,7 @@ class TestWorklist(testWorkflowMixin):
def createWorklist(self, workflow_id, *args, **kw):
workflow_value = self.getWorkflowTool()[workflow_id]
if workflow_value.__class__.__name__ == 'Workflow':
if workflow_value.getPortalType() == 'Workflow':
self.createERP5Worklist(workflow_value,*args, **kw)
else:
self.createDCWorklist(workflow_value, *args, **kw)
......@@ -125,7 +130,7 @@ class TestWorklist(testWorkflowMixin):
action=None, portal_type=None, validation_state=None,
guard_roles='', guard_expr=None, **kw):
action_name='%s (%%(count)s)' % action_name
if workflow_value.__class__.__name__ == 'Workflow':
if workflow_value.getPortalType() == 'Workflow':
if getattr(workflow_value, worklist_id, None):
workflow_value.manage_delObjects([worklist_id])
worklist_value = getattr(workflow_value, 'worklist_%s' % worklist_id, None)
......@@ -172,7 +177,7 @@ class TestWorklist(testWorkflowMixin):
def removeWorklist(self, workflow_id, worklist_id_list):
# add new workflow compatibility
workflow_value = self.getWorkflowTool()[workflow_id]
if workflow_value.__class__.__name__ == 'Workflow':
if workflow_value.getPortalType() == 'Workflow':
for worklist_id in worklist_id_list:
try:
workflow_value._delObject('worklist_'+worklist_id)
......@@ -487,13 +492,14 @@ class TestWorklist(testWorkflowMixin):
worklist_id = 'guarded_worklist'
workflow_id = 'validation_workflow'
workflow_value = self.getWorkflowTool()[workflow_id]
self.createWorklist(workflow_id, worklist_id,
action_name='guarded_test')
worklist_value = getattr(workflow_value, 'worklist_%s' % worklist_id)
# expression
worklist_value.setGuardExpression('python: "Hello, world"')
self.assertEqual(worklist_value.guard_expression.text, 'python: "Hello, world"')
if workflow_value.getPortalType() == 'Workflow':
self.createWorklist(workflow_id, worklist_id,
action_name='guarded_test')
worklist_value = getattr(workflow_value, 'worklist_%s' % worklist_id)
# expression
worklist_value.setGuardExpression('python: "Hello, world"')
self.assertEqual(worklist_value.guard_expression.text, 'python: "Hello, world"')
def test_suite():
suite = unittest.TestSuite()
......
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