mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 11:08:24 -04:00
Update post_create_template_schema
Updated the `post_create_template_schema` to check that the postage is one of our allowed values.
This commit is contained in:
@@ -18,7 +18,7 @@ post_create_template_schema = {
|
|||||||
"subject": {"type": "string"},
|
"subject": {"type": "string"},
|
||||||
"created_by": uuid,
|
"created_by": uuid,
|
||||||
"parent_folder_id": uuid,
|
"parent_folder_id": uuid,
|
||||||
"postage": {"type": "string"},
|
"postage": {"type": "string", "format": "postage"},
|
||||||
},
|
},
|
||||||
"if": {
|
"if": {
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -778,6 +778,41 @@ def test_create_a_template_with_foreign_service_reply_to(admin_request, sample_u
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('post_data, expected_errors', [
|
||||||
|
(
|
||||||
|
{},
|
||||||
|
[
|
||||||
|
{"error": "ValidationError", "message": "subject is a required property"},
|
||||||
|
{"error": "ValidationError", "message": "name is a required property"},
|
||||||
|
{"error": "ValidationError", "message": "template_type is a required property"},
|
||||||
|
{"error": "ValidationError", "message": "content is a required property"},
|
||||||
|
{"error": "ValidationError", "message": "service is a required property"},
|
||||||
|
{"error": "ValidationError", "message": "created_by is a required property"},
|
||||||
|
]
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"name": "my template", "template_type": "sms", "content": "hi", "postage": "third",
|
||||||
|
"service": "1af43c02-b5a8-4923-ad7f-5279b75ff2d0", "created_by": "30587644-9083-44d8-a114-98887f07f1e3"},
|
||||||
|
[
|
||||||
|
{"error": "ValidationError", "message": "postage invalid. It must be either first or second."},
|
||||||
|
]
|
||||||
|
),
|
||||||
|
])
|
||||||
|
def test_create_template_validates_against_json_schema(
|
||||||
|
admin_request,
|
||||||
|
sample_service_full_permissions,
|
||||||
|
post_data,
|
||||||
|
expected_errors,
|
||||||
|
):
|
||||||
|
response = admin_request.post(
|
||||||
|
'template.create_template',
|
||||||
|
service_id=sample_service_full_permissions.id,
|
||||||
|
_data=post_data,
|
||||||
|
_expected_status=400
|
||||||
|
)
|
||||||
|
assert response['errors'] == expected_errors
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('template_default, service_default',
|
@pytest.mark.parametrize('template_default, service_default',
|
||||||
[('template address', 'service address'),
|
[('template address', 'service address'),
|
||||||
(None, 'service address'),
|
(None, 'service address'),
|
||||||
|
|||||||
Reference in New Issue
Block a user