workflow_tests: fix crash on skip time with no jumps (#88404)
This commit is contained in:
parent
9afbbccb13
commit
e8d120c091
|
@ -467,16 +467,6 @@ def test_workflow_tests_automatic_jump_timeout(pub):
|
|||
new_status = workflow.add_status(name='New status')
|
||||
stalled_status = workflow.add_status(name='Stalled')
|
||||
|
||||
jump = new_status.add_action('jump')
|
||||
jump.status = stalled_status.id
|
||||
jump.timeout = 120 * 60 # 2 hours
|
||||
jump.condition = {'type': 'django', 'value': 'form_receipt_datetime|age_in_days >= 1'}
|
||||
|
||||
sendmail = new_status.add_action('sendmail')
|
||||
sendmail.to = ['test@example.org']
|
||||
sendmail.subject = 'In new status'
|
||||
sendmail.body = 'xxx'
|
||||
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -489,6 +479,27 @@ def test_workflow_tests_automatic_jump_timeout(pub):
|
|||
|
||||
testdef = TestDef.create_from_formdata(formdef, formdata)
|
||||
testdef.agent_id = user.id
|
||||
|
||||
# no jumps configured, try skipping time anyway
|
||||
testdef.workflow_tests.actions = [
|
||||
workflow_tests.SkipTime(seconds=119 * 60),
|
||||
]
|
||||
testdef.run(formdef)
|
||||
|
||||
# configure jump
|
||||
jump = new_status.add_action('jump')
|
||||
jump.status = stalled_status.id
|
||||
jump.timeout = 120 * 60 # 2 hours
|
||||
jump.condition = {'type': 'django', 'value': 'form_receipt_datetime|age_in_days >= 1'}
|
||||
|
||||
sendmail = new_status.add_action('sendmail')
|
||||
sendmail.to = ['test@example.org']
|
||||
sendmail.subject = 'In new status'
|
||||
sendmail.body = 'xxx'
|
||||
|
||||
workflow.store()
|
||||
formdef.refresh_from_storage()
|
||||
|
||||
testdef.workflow_tests.actions = [
|
||||
workflow_tests.AssertStatus(status_name='New status'),
|
||||
workflow_tests.SkipTime(seconds=119 * 60),
|
||||
|
|
|
@ -553,6 +553,9 @@ class SkipTime(WorkflowTestAction):
|
|||
if hasattr(item, 'has_valid_timeout') and item.has_valid_timeout():
|
||||
jump_actions.append(item)
|
||||
|
||||
if not jump_actions:
|
||||
return
|
||||
|
||||
delay = wf.jump.get_min_jumps_delay(jump_actions)
|
||||
|
||||
if formdata.last_update_time > formdata.frozen_receipt_time - datetime.timedelta(seconds=delay):
|
||||
|
|
Loading…
Reference in New Issue