def test__ui_demographics_submit_post_submitted(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_submit(client, dr.id) response = do_submit(client, dr.id) assert response.status_code == 302 assert response.location == url_for('ui.demographics', _external=True) assert assert__flash_messages_contains_error(client) _remove_files(dr)
def test__ui_demographics_define_columns_get_submitted(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_define_columns_post(client, dr.id, dr.columns[0], dr.columns[1], dr.columns[2], dr.columns[3], dr.columns[4], dr.columns[5], dr.columns[6]) do_submit(client, dr.id) response = client.get( url_for('ui.demographics_define_columns', id=dr.id, _external=True)) assert response.status_code == 302 assert response.location == url_for('ui.demographics', _external=True) assert assert__flash_messages_contains_error(client) _remove_files(dr)
def test__ui_demographics_delete_post__not_owner(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_define_columns_post(client, dr.id, dr.columns[0], dr.columns[1], dr.columns[2], dr.columns[3], dr.columns[4], dr.columns[5], dr.columns[6]) do_submit(client, dr.id) logout(client) user2 = login(client, faker) response = do_delete(client, dr.id) assert response.status_code == 403 _remove_files(dr)
def test__ui_demographics_no_result_created(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_define_columns_post(client, dr.id, dr.columns[0], dr.columns[1], dr.columns[2], dr.columns[3], dr.columns[4], dr.columns[5], dr.columns[6]) response = do_submit(client, dr.id) response = client.get(url_for('ui.demographics_download_result', id=dr.id, _external=True)) assert response.status_code == 404 _remove_files(dr)
def test__ui_demographics_delete_post(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_define_columns_post(client, dr.id, dr.columns[0], dr.columns[1], dr.columns[2], dr.columns[3], dr.columns[4], dr.columns[5], dr.columns[6]) do_submit(client, dr.id) response = do_delete(client, dr.id) assert response.status_code == 302 assert response.location == url_for('ui.demographics', _external=True) del_dr = DemographicsRequest.query.get(dr.id) assert del_dr.deleted == True assert del_dr.deleted_datetime is not None _assert_file_not_on_index(client, dr.filename) _remove_files(dr)
def test__ui_demographics_delete_get(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_define_columns_post(client, dr.id, dr.columns[0], dr.columns[1], dr.columns[2], dr.columns[3], dr.columns[4], dr.columns[5], dr.columns[6]) do_submit(client, dr.id) response = client.get( url_for('ui.demographics_delete', id=dr.id, _external=True)) assert response.status_code == 200 # Do not allows others to delete logout(client) user = login(client, faker) response = client.get( url_for('ui.demographics_delete', id=dr.id, _external=True)) assert response.status_code == 403 _remove_files(dr)
def test__ui_demographics_submit_post(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_define_columns_post(client, dr.id, dr.columns[0], dr.columns[1], dr.columns[2], dr.columns[3], dr.columns[4], dr.columns[5], dr.columns[6]) response = do_submit(client, dr.id) assert response.status_code == 302 assert response.location == url_for('ui.demographics', _external=True) _assert_uploaded_file_on_index(client, dr.filename, dr.id, AWAITING_COMPLETION) _remove_files(dr)
def test__ui_demographics_result_created__download(client, faker): user = login(client, faker) dr = do_create_request(client, faker, user) do_define_columns_post(client, dr.id, dr.columns[0], dr.columns[1], dr.columns[2], dr.columns[3], dr.columns[4], dr.columns[5], dr.columns[6]) response = do_submit(client, dr.id) dr.result_created_datetime = datetime.utcnow() db.session.add(dr) db.session.commit() contents = faker.text() with open(dr.result_filepath, "w") as f: f.write(contents) _assert_uploaded_file_on_index(client, dr.filename, dr.id, RESULT_CREATED) response = client.get(url_for('ui.demographics_download_result', id=dr.id, _external=True)) assert response.status_code == 200 assert response.get_data().decode("utf8") == contents dr = DemographicsRequest.query.get(dr.id) assert dr.result_downloaded_datetime is not None assert dr.result_downloaded == True # Do not allows others to download logout(client) user = login(client, faker) response = client.get(url_for('ui.demographics_download_result', id=dr.id, _external=True)) assert response.status_code == 403 _remove_files(dr)
def test__ui_demographics_submit_post_404(client, faker): user = login(client, faker) response = do_submit(client, 999) assert response.status_code == 404