45 |
45 |
return pub
|
46 |
46 |
|
47 |
47 |
|
|
48 |
@pytest.fixture
|
|
49 |
def autosave(pub):
|
|
50 |
if not pub.site_options.has_section('options'):
|
|
51 |
pub.site_options.add_section('options')
|
|
52 |
pub.site_options.set('options', 'backoffice-autosave', 'true')
|
|
53 |
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
|
54 |
pub.site_options.write(fd)
|
|
55 |
|
|
56 |
|
48 |
57 |
def teardown_module(module):
|
49 |
58 |
clean_temporary_pub()
|
50 |
59 |
|
... | ... | |
86 |
95 |
assert formdef.url_name in resp.text
|
87 |
96 |
|
88 |
97 |
resp = resp.click(formdef.name)
|
|
98 |
assert resp.pyquery('form[data-autosave=false]').length
|
89 |
99 |
resp.form['f1'] = 'test submission'
|
90 |
100 |
resp.form['f2'] = 'baz'
|
91 |
101 |
resp.form['f3'] = 'C'
|
... | ... | |
399 |
409 |
assert formdef.data_class().get(2).submission_context == {'caller': '0601020304'}
|
400 |
410 |
|
401 |
411 |
|
402 |
|
def test_backoffice_parallel_submission(pub):
|
|
412 |
def test_backoffice_parallel_submission(pub, autosave):
|
403 |
413 |
user = create_user(pub)
|
404 |
414 |
|
|
415 |
if not pub.site_options.has_section('options'):
|
|
416 |
pub.site_options.add_section('options')
|
|
417 |
pub.site_options.set('options', 'backoffice-autosave', 'true')
|
|
418 |
|
405 |
419 |
FormDef.wipe()
|
406 |
420 |
formdef = FormDef()
|
407 |
421 |
formdef.name = 'form title'
|
... | ... | |
431 |
445 |
resp3 = app.get('/backoffice/submission/form-title/%s/' % formdata.id)
|
432 |
446 |
resp3 = resp3.follow()
|
433 |
447 |
|
|
448 |
assert not resp.pyquery('form[data-autosave=false]').length
|
434 |
449 |
resp1.form['f1'] = 'foo'
|
435 |
450 |
resp1 = resp1.form.submit('submit') # to validation page
|
436 |
451 |
|
... | ... | |
466 |
481 |
assert 'This form has already been submitted.' in resp4.text
|
467 |
482 |
|
468 |
483 |
|
469 |
|
def test_backoffice_submission_autosave_tracking_code(pub):
|
|
484 |
def test_backoffice_submission_autosave_tracking_code(pub, autosave):
|
470 |
485 |
user = create_user(pub)
|
471 |
486 |
|
472 |
487 |
FormDef.wipe()
|
... | ... | |
991 |
1006 |
|
992 |
1007 |
|
993 |
1008 |
@pytest.mark.parametrize('enable_tracking_code', [True, False])
|
994 |
|
def test_backoffice_submission_prefill_user_multiple_pages(pub, enable_tracking_code):
|
|
1009 |
def test_backoffice_submission_prefill_user_multiple_pages(pub, autosave, enable_tracking_code):
|
995 |
1010 |
user = create_user(pub)
|
996 |
1011 |
other_user = pub.user_class(name='other user')
|
997 |
1012 |
other_user.email = 'other@example.net'
|