1293 |
1293 |
resp = resp.form.submit('cancel')
|
1294 |
1294 |
assert resp.location == 'http://example.net/backoffice/submission/'
|
1295 |
1295 |
|
|
1296 |
def test_backoffice_submission_with_tracking_code(pub):
|
|
1297 |
user = create_user(pub)
|
|
1298 |
create_environment(pub)
|
|
1299 |
|
|
1300 |
formdef = FormDef.get_by_urlname('form-title')
|
|
1301 |
formdef.backoffice_submission_roles = user.roles[:]
|
|
1302 |
formdef.enable_tracking_codes = True
|
|
1303 |
formdef.store()
|
|
1304 |
|
|
1305 |
app = login(get_app(pub))
|
|
1306 |
resp = app.get('/backoffice/submission/')
|
|
1307 |
|
|
1308 |
resp = resp.click(formdef.name)
|
|
1309 |
resp.form['f1'] = 'test submission'
|
|
1310 |
resp.form['f2'] = 'baz'
|
|
1311 |
resp.form['f3'] = 'C'
|
|
1312 |
resp = resp.form.submit('submit')
|
|
1313 |
assert 'Check values then click submit.' in resp.body
|
|
1314 |
# final submit
|
|
1315 |
validation_resp_body = resp.body
|
|
1316 |
resp = resp.form.submit('submit')
|
|
1317 |
|
|
1318 |
formdata_no = resp.location.split('/')[-2]
|
|
1319 |
data_class = formdef.data_class()
|
|
1320 |
formdata = data_class.get(formdata_no)
|
|
1321 |
assert formdata.tracking_code in validation_resp_body
|
|
1322 |
|
|
1323 |
formdata_location = resp.location
|
|
1324 |
resp = resp.follow() # get to the formdata page
|
|
1325 |
# check tracking code is still displayed in formdata page
|
|
1326 |
assert 'test submission' in resp.body
|
|
1327 |
assert formdata.tracking_code in resp.body
|
|
1328 |
|
|
1329 |
# check access by different user
|
|
1330 |
formdata.submission_context = {'agent_id': '10000'}
|
|
1331 |
formdata.store()
|
|
1332 |
resp = app.get(formdata_location)
|
|
1333 |
assert 'test submission' in resp.body
|
|
1334 |
assert not formdata.tracking_code in resp.body
|
|
1335 |
|
|
1336 |
# restore user
|
|
1337 |
formdata.submission_context = {'agent_id': user.id}
|
|
1338 |
formdata.store()
|
|
1339 |
resp = app.get(formdata_location)
|
|
1340 |
assert formdata.tracking_code in resp.body
|
|
1341 |
|
|
1342 |
# check access at a later time
|
|
1343 |
formdata.receipt_time = time.localtime(time.time() - 3600)
|
|
1344 |
formdata.store()
|
|
1345 |
resp = app.get(formdata_location)
|
|
1346 |
assert not formdata.tracking_code in resp.body
|
|
1347 |
|
1296 |
1348 |
def test_backoffice_submission_welco(pub, welco_url):
|
1297 |
1349 |
user = create_user(pub)
|
1298 |
1350 |
create_environment(pub)
|