mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
allow 'accepted' as a proxy for created + sending as well as 'failed' for the three failure types when querying the api
This commit is contained in:
@@ -10,10 +10,12 @@ from app.models import (
|
||||
MOBILE_TYPE,
|
||||
EMAIL_TYPE,
|
||||
NOTIFICATION_CREATED,
|
||||
NOTIFICATION_SENDING,
|
||||
NOTIFICATION_PENDING,
|
||||
NOTIFICATION_FAILED,
|
||||
NOTIFICATION_TECHNICAL_FAILURE,
|
||||
NOTIFICATION_STATUS_TYPES_FAILED
|
||||
NOTIFICATION_STATUS_TYPES_FAILED,
|
||||
NOTIFICATION_STATUS_LETTER_ACCEPTED
|
||||
)
|
||||
from tests.app.conftest import (
|
||||
sample_template as create_sample_template,
|
||||
@@ -55,8 +57,9 @@ def test_should_not_build_service_whitelist_from_invalid_contact(recipient_type,
|
||||
@pytest.mark.parametrize('initial_statuses, expected_statuses', [
|
||||
# passing in single statuses as strings
|
||||
(NOTIFICATION_FAILED, NOTIFICATION_STATUS_TYPES_FAILED),
|
||||
(NOTIFICATION_CREATED, NOTIFICATION_CREATED),
|
||||
(NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_TECHNICAL_FAILURE),
|
||||
(NOTIFICATION_STATUS_LETTER_ACCEPTED, [NOTIFICATION_SENDING, NOTIFICATION_CREATED]),
|
||||
(NOTIFICATION_CREATED, [NOTIFICATION_CREATED]),
|
||||
(NOTIFICATION_TECHNICAL_FAILURE, [NOTIFICATION_TECHNICAL_FAILURE]),
|
||||
# passing in lists containing single statuses
|
||||
([NOTIFICATION_FAILED], NOTIFICATION_STATUS_TYPES_FAILED),
|
||||
([NOTIFICATION_CREATED], [NOTIFICATION_CREATED]),
|
||||
@@ -65,13 +68,17 @@ def test_should_not_build_service_whitelist_from_invalid_contact(recipient_type,
|
||||
([NOTIFICATION_FAILED, NOTIFICATION_CREATED], NOTIFICATION_STATUS_TYPES_FAILED + [NOTIFICATION_CREATED]),
|
||||
([NOTIFICATION_CREATED, NOTIFICATION_PENDING], [NOTIFICATION_CREATED, NOTIFICATION_PENDING]),
|
||||
([NOTIFICATION_CREATED, NOTIFICATION_TECHNICAL_FAILURE], [NOTIFICATION_CREATED, NOTIFICATION_TECHNICAL_FAILURE]),
|
||||
(
|
||||
[NOTIFICATION_FAILED, NOTIFICATION_STATUS_LETTER_ACCEPTED],
|
||||
NOTIFICATION_STATUS_TYPES_FAILED + [NOTIFICATION_SENDING, NOTIFICATION_CREATED]
|
||||
),
|
||||
# checking we don't end up with duplicates
|
||||
(
|
||||
[NOTIFICATION_FAILED, NOTIFICATION_CREATED, NOTIFICATION_TECHNICAL_FAILURE],
|
||||
NOTIFICATION_STATUS_TYPES_FAILED + [NOTIFICATION_CREATED]
|
||||
),
|
||||
])
|
||||
def test_status_conversion_handles_failed_statuses(initial_statuses, expected_statuses):
|
||||
def test_status_conversion(initial_statuses, expected_statuses):
|
||||
converted_statuses = Notification.substitute_status(initial_statuses)
|
||||
assert len(converted_statuses) == len(expected_statuses)
|
||||
assert set(converted_statuses) == set(expected_statuses)
|
||||
|
||||
@@ -393,7 +393,7 @@ def test_get_all_notifications_filter_by_status_invalid_status(client, sample_no
|
||||
assert json_response['status_code'] == 400
|
||||
assert len(json_response['errors']) == 1
|
||||
assert json_response['errors'][0]['message'] == "status elephant is not one of [created, sending, sent, " \
|
||||
"delivered, pending, failed, technical-failure, temporary-failure, permanent-failure]"
|
||||
"delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, accepted]"
|
||||
|
||||
|
||||
def test_get_all_notifications_filter_by_multiple_statuses(client, sample_template):
|
||||
|
||||
@@ -26,7 +26,7 @@ def test_get_notifications_request_invalid_statuses(
|
||||
):
|
||||
partial_error_status = "is not one of " \
|
||||
"[created, sending, sent, delivered, pending, failed, " \
|
||||
"technical-failure, temporary-failure, permanent-failure]"
|
||||
"technical-failure, temporary-failure, permanent-failure, accepted]"
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate({'status': invalid_statuses + valid_statuses}, get_notifications_request)
|
||||
@@ -73,7 +73,7 @@ def test_get_notifications_request_invalid_statuses_and_template_types():
|
||||
error_messages = [error['message'] for error in errors]
|
||||
for invalid_status in ["elephant", "giraffe"]:
|
||||
assert "status {} is not one of [created, sending, sent, delivered, " \
|
||||
"pending, failed, technical-failure, temporary-failure, permanent-failure]".format(
|
||||
"pending, failed, technical-failure, temporary-failure, permanent-failure, accepted]".format(
|
||||
invalid_status
|
||||
) in error_messages
|
||||
|
||||
|
||||
Reference in New Issue
Block a user