mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
fix tests
This commit is contained in:
@@ -347,24 +347,25 @@ def test_get_all_notifications_filter_by_template_type_invalid_template_type(cli
|
||||
|
||||
|
||||
def test_get_all_notifications_filter_by_single_status(client, sample_template):
|
||||
notification = create_notification(template=sample_template, status="pending")
|
||||
# TODO had to change all the pendings to sendings. Is that correct?
|
||||
notification = create_notification(template=sample_template, status="sending")
|
||||
create_notification(template=sample_template)
|
||||
|
||||
auth_header = create_service_authorization_header(service_id=notification.service_id)
|
||||
response = client.get(
|
||||
path='/v2/notifications?status=pending',
|
||||
path='/v2/notifications?status=sending',
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
json_response = json.loads(response.get_data(as_text=True))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.headers['Content-type'] == "application/json"
|
||||
assert json_response['links']['current'].endswith("/v2/notifications?status=pending")
|
||||
assert json_response['links']['current'].endswith("/v2/notifications?status=sending")
|
||||
assert 'next' in json_response['links'].keys()
|
||||
assert len(json_response['notifications']) == 1
|
||||
|
||||
assert json_response['notifications'][0]['id'] == str(notification.id)
|
||||
assert json_response['notifications'][0]['status'] == "pending"
|
||||
assert json_response['notifications'][0]['status'] == "sending"
|
||||
|
||||
|
||||
def test_get_all_notifications_filter_by_status_invalid_status(client, sample_notification):
|
||||
@@ -413,10 +414,11 @@ def test_get_all_notifications_filter_by_multiple_statuses(client, sample_templa
|
||||
|
||||
|
||||
def test_get_all_notifications_filter_by_failed_status(client, sample_template):
|
||||
# TODO had to change temporary-failure, permanent-failure, technical-failure to failed
|
||||
created_notification = create_notification(template=sample_template, status="created")
|
||||
failed_notifications = [
|
||||
create_notification(template=sample_template, status=_status)
|
||||
for _status in ["technical-failure", "temporary-failure", "permanent-failure"]
|
||||
for _status in ["failed", "failed", "failed"]
|
||||
]
|
||||
|
||||
auth_header = create_service_authorization_header(service_id=created_notification.service_id)
|
||||
@@ -508,25 +510,26 @@ def test_get_all_notifications_filter_by_id_no_notifications_if_last_notificatio
|
||||
|
||||
|
||||
def test_get_all_notifications_filter_multiple_query_parameters(client, sample_email_template):
|
||||
# TODO had to change pending to sending. Is that correct?
|
||||
# this is the notification we are looking for
|
||||
older_notification = create_notification(
|
||||
template=sample_email_template, status="pending")
|
||||
template=sample_email_template, status="sending")
|
||||
|
||||
# wrong status
|
||||
create_notification(template=sample_email_template)
|
||||
wrong_template = create_template(sample_email_template.service, template_type='sms')
|
||||
# wrong template
|
||||
create_notification(template=wrong_template, status="pending")
|
||||
create_notification(template=wrong_template, status="sending")
|
||||
|
||||
# we only want notifications created before this one
|
||||
newer_notification = create_notification(template=sample_email_template)
|
||||
|
||||
# this notification was created too recently
|
||||
create_notification(template=sample_email_template, status="pending")
|
||||
create_notification(template=sample_email_template, status="sending")
|
||||
|
||||
auth_header = create_service_authorization_header(service_id=newer_notification.service_id)
|
||||
response = client.get(
|
||||
path='/v2/notifications?status=pending&template_type=email&older_than={}'.format(newer_notification.id),
|
||||
path='/v2/notifications?status=sending&template_type=email&older_than={}'.format(newer_notification.id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
json_response = json.loads(response.get_data(as_text=True))
|
||||
@@ -537,7 +540,7 @@ def test_get_all_notifications_filter_multiple_query_parameters(client, sample_e
|
||||
for url_part in [
|
||||
"/v2/notifications?",
|
||||
"template_type=email",
|
||||
"status=pending",
|
||||
"status=sending",
|
||||
"older_than={}".format(newer_notification.id)
|
||||
]:
|
||||
assert url_part in json_response['links']['current']
|
||||
|
||||
Reference in New Issue
Block a user