Make get all notications return in csv format too:

* This adds functionality (via an extra req param) to the
* existing get all notifications method allowing us to specify
* when we want the API to return in csv/non-csv format
This commit is contained in:
Imdad Ahad
2017-04-20 12:31:49 +01:00
parent 9fbd43c072
commit 4dfd5448ad
3 changed files with 37 additions and 10 deletions

View File

@@ -715,3 +715,31 @@ def create_10_jobs(db, session, service, template):
for _ in range(10):
the_time.tick(timedelta(hours=1))
create_job(db, session, service, template)
def test_get_all_notifications_for_job_returns_csv_format(
client,
notify_db,
notify_db_session,
):
job = create_job(notify_db, notify_db_session)
notification = create_notification(
notify_db,
notify_db_session,
job=job,
job_row_number=1,
created_at=datetime.utcnow(),
)
response = client.get(
path='/service/{}/job/{}/notifications?'.format(notification.service.id, job.id, True),
headers=[create_authorization_header()],
query_string={'format_for_csv': True}
)
assert response.status_code == 200
resp = json.loads(response.get_data(as_text=True))
assert len(resp['notifications']) == 1
notification = resp['notifications'][0]
assert set(notification.keys()) == \
set(['created_at', 'template_type', 'template_name', 'job_name', 'status', 'row_number', 'recipient'])