workflows: detect obsolete status in global actions timeout triggers (#34528)
This commit is contained in:
parent
3db2829e6e
commit
d157723e20
|
@ -3100,6 +3100,16 @@ def test_global_timeouts(two_pubs):
|
|||
assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'yellow'
|
||||
|
||||
formdata1.store() # reset
|
||||
|
||||
# bad (obsolete) status: do nothing
|
||||
trigger.anchor_status_first = 'wf-foobar'
|
||||
workflow.store()
|
||||
formdata1.evolution[-1].time = time.localtime(time.time()-3*86400)
|
||||
formdata1.store()
|
||||
pub.apply_global_action_timeouts()
|
||||
assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'green'
|
||||
formdata1.store()
|
||||
|
||||
trigger.anchor = 'latest-arrival'
|
||||
trigger.anchor_status_latest = None
|
||||
workflow.store()
|
||||
|
@ -3135,6 +3145,13 @@ def test_global_timeouts(two_pubs):
|
|||
assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'yellow'
|
||||
formdata1.store()
|
||||
|
||||
# bad (obsolete) status: do nothing
|
||||
trigger.anchor_status_latest = 'wf-foobar'
|
||||
workflow.store()
|
||||
pub.apply_global_action_timeouts()
|
||||
assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'green'
|
||||
formdata1.store()
|
||||
|
||||
# check trigger is not run on finalized formdata
|
||||
formdata1.jump_status('finished')
|
||||
formdata1.evolution[-1].time = time.localtime(time.time()-4*86400)
|
||||
|
|
|
@ -1017,7 +1017,20 @@ class WorkflowGlobalActionTimeoutTrigger(WorkflowGlobalActionTrigger):
|
|||
])
|
||||
|
||||
def properly_configured(self):
|
||||
return bool(self.anchor and self.timeout)
|
||||
workflow = self.parent.parent
|
||||
if not (self.anchor and self.timeout):
|
||||
return False
|
||||
if self.anchor == '1st-arrival' and self.anchor_status_first:
|
||||
try:
|
||||
workflow.get_status(self.anchor_status_first)
|
||||
except KeyError:
|
||||
return False
|
||||
if self.anchor == 'latest-arrival' and self.anchor_status_latest:
|
||||
try:
|
||||
workflow.get_status(self.anchor_status_latest)
|
||||
except KeyError:
|
||||
return False
|
||||
return True
|
||||
|
||||
def render_as_line(self):
|
||||
if self.properly_configured():
|
||||
|
|
Loading…
Reference in New Issue