2430 |
2430 |
_apply_timeouts(two_pubs)
|
2431 |
2431 |
|
2432 |
2432 |
|
|
2433 |
def test_timeout_with_humantime_template(two_pubs):
|
|
2434 |
workflow = Workflow(name='timeout')
|
|
2435 |
st1 = workflow.add_status('Status1', 'st1')
|
|
2436 |
workflow.add_status('Status2', 'st2')
|
|
2437 |
|
|
2438 |
jump = JumpWorkflowStatusItem()
|
|
2439 |
jump.id = '_jump'
|
|
2440 |
jump.by = ['_submitter', '_receiver']
|
|
2441 |
jump.timeout = '{{ 30 }} minutes'
|
|
2442 |
jump.status = 'st2'
|
|
2443 |
st1.items.append(jump)
|
|
2444 |
jump.parent = st1
|
|
2445 |
|
|
2446 |
workflow.store()
|
|
2447 |
|
|
2448 |
formdef = FormDef()
|
|
2449 |
formdef.name = 'baz'
|
|
2450 |
formdef.fields = []
|
|
2451 |
formdef.workflow_id = workflow.id
|
|
2452 |
assert formdef.get_workflow().id == workflow.id
|
|
2453 |
formdef.store()
|
|
2454 |
|
|
2455 |
formdata = formdef.data_class()()
|
|
2456 |
formdata.just_created()
|
|
2457 |
formdata.store()
|
|
2458 |
formdata_id = formdata.id
|
|
2459 |
|
|
2460 |
_apply_timeouts(two_pubs)
|
|
2461 |
assert formdef.data_class().get(formdata_id).status == 'wf-st1' # no change
|
|
2462 |
|
|
2463 |
rewind(formdata, seconds=40 * 60)
|
|
2464 |
formdata.store()
|
|
2465 |
_apply_timeouts(two_pubs)
|
|
2466 |
assert formdef.data_class().get(formdata_id).status == 'wf-st2'
|
|
2467 |
|
|
2468 |
# invalid timeout value
|
|
2469 |
jump.timeout = '{{ 30 }} plop'
|
|
2470 |
workflow.store()
|
|
2471 |
formdef.refresh_from_storage()
|
|
2472 |
|
|
2473 |
formdata = formdef.data_class()()
|
|
2474 |
formdata.just_created()
|
|
2475 |
formdata.store()
|
|
2476 |
formdata_id = formdata.id
|
|
2477 |
|
|
2478 |
if two_pubs.is_using_postgresql():
|
|
2479 |
two_pubs.loggederror_class.wipe()
|
|
2480 |
|
|
2481 |
rewind(formdata, seconds=40 * 60)
|
|
2482 |
formdata.store()
|
|
2483 |
_apply_timeouts(two_pubs)
|
|
2484 |
assert formdef.data_class().get(formdata_id).status == 'wf-st1' # no change
|
|
2485 |
|
|
2486 |
if two_pubs.is_using_postgresql():
|
|
2487 |
assert two_pubs.loggederror_class.count() == 1
|
|
2488 |
logged_error = two_pubs.loggederror_class.select()[0]
|
|
2489 |
assert logged_error.summary == "Error in timeout value ('30 plop')"
|
|
2490 |
|
|
2491 |
|
2433 |
2492 |
def test_legacy_timeout(pub):
|
2434 |
2493 |
workflow = Workflow(name='timeout')
|
2435 |
2494 |
st1 = workflow.add_status('Status1', 'st1')
|
... | ... | |
2541 |
2600 |
pytest.skip('this requires SQL')
|
2542 |
2601 |
return
|
2543 |
2602 |
|
|
2603 |
FormDef.wipe()
|
|
2604 |
Workflow.wipe()
|
|
2605 |
|
2544 |
2606 |
workflow = Workflow(name='jump-mark')
|
2545 |
2607 |
st1 = workflow.add_status('Status1', 'st1')
|
2546 |
2608 |
|
... | ... | |
5482 |
5544 |
formdef.workflow_id = workflow.id
|
5483 |
5545 |
formdef.store()
|
5484 |
5546 |
|
|
5547 |
formdef.data_class().wipe()
|
|
5548 |
|
5485 |
5549 |
formdata1 = formdef.data_class()()
|
5486 |
5550 |
formdata1.data = {'1': 'foo'}
|
5487 |
5551 |
formdata1.just_created()
|