mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-16 20:48:37 -04:00
Fixing tests, fixing tests...
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -410,7 +410,7 @@ def test_get_all_notifications_filter_by_template_type_invalid_template_type(
|
||||
assert len(json_response["errors"]) == 1
|
||||
assert (
|
||||
json_response["errors"][0]["message"]
|
||||
== "template_type orange is not one of [sms, email, letter]"
|
||||
== f"template_type orange is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
)
|
||||
|
||||
|
||||
@@ -463,9 +463,7 @@ def test_get_all_notifications_filter_by_status_invalid_status(
|
||||
assert len(json_response["errors"]) == 1
|
||||
assert (
|
||||
json_response["errors"][0]["message"]
|
||||
== "status elephant is not one of [cancelled, created, sending, "
|
||||
"sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, "
|
||||
"pending-virus-check, validation-failed, virus-scan-failed]"
|
||||
== f"status elephant is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in NotificationStatus])}]"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -43,12 +43,7 @@ def test_get_notifications_valid_json(input):
|
||||
],
|
||||
)
|
||||
def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_statuses):
|
||||
partial_error_status = (
|
||||
"is not one of "
|
||||
"[cancelled, created, sending, sent, delivered, pending, failed, "
|
||||
"technical-failure, temporary-failure, permanent-failure, pending-virus-check, "
|
||||
"validation-failed, virus-scan-failed]"
|
||||
)
|
||||
partial_error_status = f"is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in NotificationStatus])}]"
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(
|
||||
@@ -75,7 +70,7 @@ def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_stat
|
||||
def test_get_notifications_request_invalid_template_types(
|
||||
invalid_template_types, valid_template_types
|
||||
):
|
||||
partial_error_template_type = "is not one of [sms, email, letter]"
|
||||
partial_error_template_type = f"is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(
|
||||
@@ -108,15 +103,13 @@ 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 (
|
||||
f"status {invalid_status} is not one of [cancelled, created, sending, sent, delivered, "
|
||||
"pending, failed, technical-failure, temporary-failure, permanent-failure, "
|
||||
"pending-virus-check, validation-failed, virus-scan-failed]"
|
||||
f"status {invalid_status} is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in NotificationStatus])}]"
|
||||
in error_messages
|
||||
)
|
||||
|
||||
for invalid_template_type in ["orange", "avocado"]:
|
||||
assert (
|
||||
f"template_type {invalid_template_type} is not one of [sms, email, letter]"
|
||||
f"template_type {invalid_template_type} is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
in error_messages
|
||||
)
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ def test_post_sms_notification_returns_201(
|
||||
assert resp_json["template"]["version"] == sample_template_with_placeholders.version
|
||||
assert (
|
||||
f"services/{sample_template_with_placeholders.service_id}/templates/"
|
||||
f"{sample_template_with_placeholders.service_id}"
|
||||
f"{sample_template_with_placeholders.id}"
|
||||
) in resp_json["template"]["uri"]
|
||||
assert not resp_json["scheduled_for"]
|
||||
assert mocked.called
|
||||
|
||||
@@ -120,7 +120,7 @@ def test_get_all_templates_for_invalid_type_returns_400(client, sample_service):
|
||||
"status_code": 400,
|
||||
"errors": [
|
||||
{
|
||||
"message": "type coconut is not one of [sms, email, letter]",
|
||||
"message": f"type coconut is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]",
|
||||
"error": "ValidationError",
|
||||
}
|
||||
],
|
||||
|
||||
@@ -280,7 +280,7 @@ def test_get_all_template_request_schema_against_invalid_args_is_invalid(templat
|
||||
assert len(errors["errors"]) == 1
|
||||
assert (
|
||||
errors["errors"][0]["message"]
|
||||
== "type unknown is not one of [sms, email, letter]"
|
||||
== f"type unknown is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user