mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 06:52:06 -05:00
Update rest endpoint to handle include_jobs arg
This commit is contained in:
@@ -295,6 +295,34 @@ def test_get_all_notifications_returns_200(client, sample_template):
|
||||
assert not json_response['notifications'][0]['scheduled_for']
|
||||
|
||||
|
||||
def test_get_all_notifications_with_include_jobs_arg_returns_200(
|
||||
client, sample_template, sample_job
|
||||
):
|
||||
notifications = [
|
||||
create_notification(template=sample_template, job=sample_job),
|
||||
create_notification(template=sample_template)
|
||||
]
|
||||
notification = notifications[-1]
|
||||
|
||||
auth_header = create_authorization_header(service_id=notification.service_id)
|
||||
response = client.get(
|
||||
path='/v2/notifications?include_jobs=true',
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
json_response = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert json_response['links']['current'].endswith("/v2/notifications?include_jobs=true")
|
||||
assert 'next' in json_response['links'].keys()
|
||||
assert len(json_response['notifications']) == 2
|
||||
|
||||
assert json_response['notifications'][0]['id'] == str(notification.id)
|
||||
assert json_response['notifications'][0]['status'] == notification.status
|
||||
assert json_response['notifications'][0]['phone_number'] == notification.to
|
||||
assert json_response['notifications'][0]['type'] == notification.template.template_type
|
||||
assert not json_response['notifications'][0]['scheduled_for']
|
||||
|
||||
|
||||
def test_get_all_notifications_no_notifications_if_no_notifications(client, sample_service):
|
||||
auth_header = create_authorization_header(service_id=sample_service.id)
|
||||
response = client.get(
|
||||
|
||||
Reference in New Issue
Block a user