mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
@@ -408,9 +408,12 @@ def test_get_all_notifications_filter_by_template_type_invalid_template_type(
|
||||
|
||||
assert json_response["status_code"] == 400
|
||||
assert len(json_response["errors"]) == 1
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in TemplateType]
|
||||
)
|
||||
assert (
|
||||
json_response["errors"][0]["message"]
|
||||
== f"template_type orange is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
== f"template_type orange is not one of [{type_str}]"
|
||||
)
|
||||
|
||||
|
||||
@@ -461,9 +464,12 @@ def test_get_all_notifications_filter_by_status_invalid_status(
|
||||
|
||||
assert json_response["status_code"] == 400
|
||||
assert len(json_response["errors"]) == 1
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in NotificationStatus]
|
||||
)
|
||||
assert (
|
||||
json_response["errors"][0]["message"]
|
||||
== f"status elephant is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in NotificationStatus])}]"
|
||||
== f"status elephant is not one of [{type_str}]"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ def test_get_notifications_valid_json(input):
|
||||
],
|
||||
)
|
||||
def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_statuses):
|
||||
partial_error_status = f"is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in NotificationStatus])}]"
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in NotificationStatus]
|
||||
)
|
||||
partial_error_status = f"is not one of [{type_str}]"
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(
|
||||
@@ -70,7 +73,10 @@ 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 = f"is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in TemplateType]
|
||||
)
|
||||
partial_error_template_type = f"is not one of [{type_str}]"
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(
|
||||
@@ -101,15 +107,18 @@ def test_get_notifications_request_invalid_statuses_and_template_types():
|
||||
assert len(errors) == 4
|
||||
|
||||
error_messages = [error["message"] for error in errors]
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in NotificationStatus]
|
||||
)
|
||||
for invalid_status in ["elephant", "giraffe"]:
|
||||
assert (
|
||||
f"status {invalid_status} is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in NotificationStatus])}]"
|
||||
in error_messages
|
||||
)
|
||||
assert f"status {invalid_status} is not one of [{type_str}]" in error_messages
|
||||
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in TemplateType]
|
||||
)
|
||||
for invalid_template_type in ["orange", "avocado"]:
|
||||
assert (
|
||||
f"template_type {invalid_template_type} is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
f"template_type {invalid_template_type} is not one of [{type_str}]"
|
||||
in error_messages
|
||||
)
|
||||
|
||||
|
||||
@@ -116,11 +116,14 @@ def test_get_all_templates_for_invalid_type_returns_400(client, sample_service):
|
||||
|
||||
json_response = json.loads(response.get_data(as_text=True))
|
||||
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in TemplateType]
|
||||
)
|
||||
assert json_response == {
|
||||
"status_code": 400,
|
||||
"errors": [
|
||||
{
|
||||
"message": f"type coconut is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]",
|
||||
"message": f"type coconut is not one of [{type_str}]",
|
||||
"error": "ValidationError",
|
||||
}
|
||||
],
|
||||
|
||||
@@ -278,10 +278,10 @@ def test_get_all_template_request_schema_against_invalid_args_is_invalid(templat
|
||||
|
||||
assert errors["status_code"] == 400
|
||||
assert len(errors["errors"]) == 1
|
||||
assert (
|
||||
errors["errors"][0]["message"]
|
||||
== f"type unknown is not one of [{', '.join([f'<{type(e).__name__}.{e.name}: {e.value}>'for e in TemplateType])}]"
|
||||
type_str = ", ".join(
|
||||
[f"<{type(e).__name__}.{e.name}: {e.value}>" for e in TemplateType]
|
||||
)
|
||||
assert errors["errors"][0]["message"] == f"type unknown is not one of [{type_str}]"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("response", valid_json_get_all_response)
|
||||
|
||||
Reference in New Issue
Block a user