mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
More fixes for everyone.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -58,9 +58,7 @@ def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_stat
|
||||
errors = json.loads(str(e.value)).get("errors")
|
||||
assert len(errors) == len(invalid_statuses)
|
||||
for index, value in enumerate(invalid_statuses):
|
||||
assert errors[index]["message"] == "status {} {}".format(
|
||||
value, partial_error_status
|
||||
)
|
||||
assert errors[index]["message"] == f"status {value} {partial_error_status}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -71,13 +69,13 @@ def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_stat
|
||||
# multiple invalid template_types
|
||||
(["orange", "avocado", "banana"], []),
|
||||
# one bad template_type and one good template_type
|
||||
(["orange"], ["sms"]),
|
||||
(["orange"], [TemplateType.SMS]),
|
||||
],
|
||||
)
|
||||
def test_get_notifications_request_invalid_template_types(
|
||||
invalid_template_types, valid_template_types
|
||||
):
|
||||
partial_error_template_type = "is not one of [sms, email]"
|
||||
partial_error_template_type = "is not one of [sms, email, letter]"
|
||||
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(
|
||||
@@ -88,8 +86,8 @@ def test_get_notifications_request_invalid_template_types(
|
||||
errors = json.loads(str(e.value)).get("errors")
|
||||
assert len(errors) == len(invalid_template_types)
|
||||
for index, value in enumerate(invalid_template_types):
|
||||
assert errors[index]["message"] == "template_type {} {}".format(
|
||||
value, partial_error_template_type
|
||||
assert errors[index]["message"] == (
|
||||
f"template_type {value} {partial_error_template_type}"
|
||||
)
|
||||
|
||||
|
||||
@@ -97,8 +95,8 @@ def test_get_notifications_request_invalid_statuses_and_template_types():
|
||||
with pytest.raises(ValidationError) as e:
|
||||
validate(
|
||||
{
|
||||
"status": ["created", "elephant", "giraffe"],
|
||||
"template_type": ["sms", "orange", "avocado"],
|
||||
"status": [NotificationStatus.CREATED, "elephant", "giraffe"],
|
||||
"template_type": [TemplateType.SMS, "orange", "avocado"],
|
||||
},
|
||||
get_notifications_request,
|
||||
)
|
||||
@@ -110,17 +108,15 @@ 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 [cancelled, created, sending, sent, delivered, "
|
||||
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]".format(
|
||||
invalid_status
|
||||
)
|
||||
"pending-virus-check, validation-failed, virus-scan-failed]"
|
||||
in error_messages
|
||||
)
|
||||
|
||||
for invalid_template_type in ["orange", "avocado"]:
|
||||
assert (
|
||||
"template_type {} is not one of [sms, email]".format(invalid_template_type)
|
||||
f"template_type {invalid_template_type} is not one of [sms, email, letter]"
|
||||
in error_messages
|
||||
)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ def test_get_all_templates_returns_200(client, sample_service):
|
||||
create_template(
|
||||
sample_service,
|
||||
template_type=tmp_type,
|
||||
subject="subject_{}".format(name) if tmp_type == TemplateType.EMAIL else "",
|
||||
subject=f"subject_{name}" if tmp_type == TemplateType.EMAIL else "",
|
||||
template_name=name,
|
||||
)
|
||||
for name, tmp_type in product(("A", "B", "C"), TemplateType)
|
||||
@@ -47,8 +47,8 @@ def test_get_all_templates_for_valid_type_returns_200(client, sample_service, tm
|
||||
create_template(
|
||||
sample_service,
|
||||
template_type=tmp_type,
|
||||
template_name="Template {}".format(i),
|
||||
subject="subject_{}".format(i) if tmp_type == TemplateType.EMAIL else "",
|
||||
template_name=f"Template {i}",
|
||||
subject=f"subject_{i}" if tmp_type == TemplateType.EMAIL else "",
|
||||
)
|
||||
for i in range(3)
|
||||
]
|
||||
@@ -56,7 +56,7 @@ def test_get_all_templates_for_valid_type_returns_200(client, sample_service, tm
|
||||
auth_header = create_service_authorization_header(service_id=sample_service.id)
|
||||
|
||||
response = client.get(
|
||||
path="/v2/templates?type={}".format(tmp_type),
|
||||
path=f"/v2/templates?type={tmp_type}",
|
||||
headers=[("Content-Type", "application/json"), auth_header],
|
||||
)
|
||||
|
||||
@@ -92,7 +92,7 @@ def test_get_correct_num_templates_for_valid_type_returns_200(
|
||||
auth_header = create_service_authorization_header(service_id=sample_service.id)
|
||||
|
||||
response = client.get(
|
||||
path="/v2/templates?type={}".format(tmp_type),
|
||||
path=f"/v2/templates?type={tmp_type}",
|
||||
headers=[("Content-Type", "application/json"), auth_header],
|
||||
)
|
||||
|
||||
@@ -109,7 +109,7 @@ def test_get_all_templates_for_invalid_type_returns_400(client, sample_service):
|
||||
invalid_type = "coconut"
|
||||
|
||||
response = client.get(
|
||||
path="/v2/templates?type={}".format(invalid_type),
|
||||
path=f"/v2/templates?type={invalid_type}",
|
||||
headers=[("Content-Type", "application/json"), auth_header],
|
||||
)
|
||||
|
||||
@@ -122,7 +122,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]",
|
||||
"message": "type coconut is not one of [sms, email, letter]",
|
||||
"error": "ValidationError",
|
||||
}
|
||||
],
|
||||
|
||||
@@ -278,7 +278,7 @@ 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"] == "type unknown is not one of [sms, email]"
|
||||
assert errors["errors"][0]["message"] == "type unknown is not one of [sms, email, letter]"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("response", valid_json_get_all_response)
|
||||
|
||||
Reference in New Issue
Block a user