Commit fd54bf81 authored by Romain Courteaud's avatar Romain Courteaud

Check if int variable are managed by workflist.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18431 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4bf144c1
...@@ -57,6 +57,11 @@ class TestWorklist(ERP5TypeTestCase): ...@@ -57,6 +57,11 @@ class TestWorklist(ERP5TypeTestCase):
worklist_wrong_state_id = '%s_wrong_state' % worklist_owner_id worklist_wrong_state_id = '%s_wrong_state' % worklist_owner_id
actbox_wrong_state = '%s_wrong_state' % actbox_owner_name actbox_wrong_state = '%s_wrong_state' % actbox_owner_name
worklist_int_variable_id = 'int_value_workflist'
actbox_int_variable_name = 'int_value_todo'
int_catalogued_variable_id = 'int_index'
int_value = 1
def getTitle(self): def getTitle(self):
return "Worklist" return "Worklist"
...@@ -135,6 +140,7 @@ class TestWorklist(ERP5TypeTestCase): ...@@ -135,6 +140,7 @@ class TestWorklist(ERP5TypeTestCase):
def createDocument(self): def createDocument(self):
module = self.getPortal().getDefaultModule(self.checked_portal_type) module = self.getPortal().getDefaultModule(self.checked_portal_type)
result = module.newContent(portal_type=self.checked_portal_type) result = module.newContent(portal_type=self.checked_portal_type)
result.setProperty(self.int_catalogued_variable_id, self.int_value)
assert result.getValidationState() == self.checked_validation_state assert result.getValidationState() == self.checked_validation_state
return result return result
...@@ -144,21 +150,37 @@ class TestWorklist(ERP5TypeTestCase): ...@@ -144,21 +150,37 @@ class TestWorklist(ERP5TypeTestCase):
self.assertNotEquals(left_parenthesis_offset, -1) self.assertNotEquals(left_parenthesis_offset, -1)
return int(action_name[left_parenthesis_offset + 1:-1]) return int(action_name[left_parenthesis_offset + 1:-1])
def associatePropertySheet(self):
from Products.ERP5Type.Base import _aq_reset
ti = self.getTypesTool().getTypeInfo(self.checked_portal_type)
ti.property_sheet_list = list(ti.property_sheet_list) + \
['SortIndex']
# reset aq_dynamic cache
_aq_reset()
def addWorkflowCataloguedVariable(self):
workflow = self.getWorkflowTool()[self.checked_workflow]
workflow.variables.addVariable(self.int_catalogued_variable_id)
variable = getattr(workflow.variables, self.int_catalogued_variable_id)
def createWorklist(self): def createWorklist(self):
workflow = self.getWorkflowTool()[self.checked_workflow] workflow = self.getWorkflowTool()[self.checked_workflow]
worklists = workflow.worklists worklists = workflow.worklists
for worklist_id, actbox_name, role, expr, state in [ for worklist_id, actbox_name, role, expr, state, int_variable in [
(self.worklist_assignor_id, self.actbox_assignor_name, (self.worklist_assignor_id, self.actbox_assignor_name,
'Assignor', None, self.checked_validation_state), 'Assignor', None, self.checked_validation_state, None),
(self.worklist_owner_id, self.actbox_owner_name, (self.worklist_owner_id, self.actbox_owner_name,
'Owner', None, self.checked_validation_state), 'Owner', None, self.checked_validation_state, None),
(self.worklist_desactivated_id, self.actbox_desactivated_by_expression, (self.worklist_desactivated_id, self.actbox_desactivated_by_expression,
'Owner', 'python: 0', self.checked_validation_state), 'Owner', 'python: 0', self.checked_validation_state, None),
(self.worklist_wrong_state_id, self.actbox_wrong_state, (self.worklist_wrong_state_id, self.actbox_wrong_state,
'Owner', None, self.not_checked_validation_state), 'Owner', None, self.not_checked_validation_state, None),
(self.worklist_assignor_owner_id, self.actbox_assignor_owner_name, (self.worklist_assignor_owner_id, self.actbox_assignor_owner_name,
'Assignor; Owner', None, self.checked_validation_state)]: 'Assignor; Owner', None, self.checked_validation_state, None),
(self.worklist_int_variable_id, self.actbox_int_variable_name,
None, None, None, str(self.int_value)),
]:
worklists.addWorklist(worklist_id) worklists.addWorklist(worklist_id)
worklist_definition = worklists._getOb(worklist_id) worklist_definition = worklists._getOb(worklist_id)
worklist_definition.setProperties('', worklist_definition.setProperties('',
...@@ -166,6 +188,9 @@ class TestWorklist(ERP5TypeTestCase): ...@@ -166,6 +188,9 @@ class TestWorklist(ERP5TypeTestCase):
props={'guard_roles': role, props={'guard_roles': role,
'var_match_portal_type': self.checked_portal_type, 'var_match_portal_type': self.checked_portal_type,
'var_match_validation_state': state, 'var_match_validation_state': state,
# Variable value is saved as string in worklist
'var_match_%s' % self.int_catalogued_variable_id: \
int_variable,
'guard_expr': expr}) 'guard_expr': expr})
def clearCache(self): def clearCache(self):
...@@ -184,6 +209,8 @@ class TestWorklist(ERP5TypeTestCase): ...@@ -184,6 +209,8 @@ class TestWorklist(ERP5TypeTestCase):
self.createManagerAndLogin() self.createManagerAndLogin()
self.createUsers() self.createUsers()
self.logMessage("Create worklist") self.logMessage("Create worklist")
self.associatePropertySheet()
self.addWorkflowCataloguedVariable()
self.createWorklist() self.createWorklist()
self.logMessage("Create document as Manager") self.logMessage("Create document as Manager")
document = self.createDocument() document = self.createDocument()
...@@ -334,6 +361,32 @@ class TestWorklist(ERP5TypeTestCase): ...@@ -334,6 +361,32 @@ class TestWorklist(ERP5TypeTestCase):
self.assertEquals(len(entry_list), 0) self.assertEquals(len(entry_list), 0)
self.logout() self.logout()
# Check if int variable are managed by the worklist
user_id = 'manager'
self.login(user_id)
result = workflow_tool.listActions(object=document)
self.logMessage("Check %s worklist with int value as %s" % \
(user_id, self.int_value))
entry_list = [x for x in result \
if x['name'].startswith(self.actbox_int_variable_name)]
self.assertEquals(len(entry_list), 1)
# Change int value on document
new_value = self.int_value + 1
document.setProperty(self.int_catalogued_variable_id, new_value)
get_transaction().commit()
self.tic()
self.clearCache()
result = workflow_tool.listActions(object=document)
self.logMessage("Check %s worklist with int value as %s" % \
(user_id, new_value))
entry_list = [x for x in result \
if x['name'].startswith(self.actbox_int_variable_name)]
self.assertEquals(len(entry_list), 0)
self.logout()
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestWorklist)) suite.addTest(unittest.makeSuite(TestWorklist))
......
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