mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
from flask import json
|
||||
|
||||
from app.models import EMAIL_TYPE, SMS_TYPE, TEMPLATE_TYPES
|
||||
from app.models import TemplateType
|
||||
from app.utils import DATETIME_FORMAT
|
||||
from tests import create_service_authorization_header
|
||||
from tests.app.db import create_template
|
||||
@@ -12,8 +12,8 @@ valid_version_params = [None, 1]
|
||||
@pytest.mark.parametrize(
|
||||
"tmp_type, expected_name, expected_subject",
|
||||
[
|
||||
(SMS_TYPE, "sms Template Name", None),
|
||||
(EMAIL_TYPE, "email Template Name", "Template subject"),
|
||||
(TemplateType.SMS, "sms Template Name", None),
|
||||
(TemplateType.EMAIL, "email Template Name", "Template subject"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("version", valid_version_params)
|
||||
@@ -56,7 +56,7 @@ def test_get_template_by_id_returns_200(
|
||||
[
|
||||
(
|
||||
{
|
||||
"template_type": SMS_TYPE,
|
||||
"template_type": TemplateType.SMS,
|
||||
"content": "Hello ((placeholder)) ((conditional??yes))",
|
||||
},
|
||||
{
|
||||
@@ -66,7 +66,7 @@ def test_get_template_by_id_returns_200(
|
||||
),
|
||||
(
|
||||
{
|
||||
"template_type": EMAIL_TYPE,
|
||||
"template_type": TemplateType.EMAIL,
|
||||
"subject": "((subject))",
|
||||
"content": "((content))",
|
||||
},
|
||||
@@ -120,7 +120,7 @@ def test_get_template_with_non_existent_template_id_returns_404(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tmp_type", TEMPLATE_TYPES)
|
||||
@pytest.mark.parametrize("tmp_type", list(TemplateType))
|
||||
def test_get_template_with_non_existent_version_returns_404(
|
||||
client, sample_service, tmp_type
|
||||
):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
from flask import json
|
||||
|
||||
from app.models import EMAIL_TYPE, TEMPLATE_TYPES
|
||||
from app.models import TemplateType
|
||||
from tests import create_service_authorization_header
|
||||
from tests.app.db import create_template
|
||||
|
||||
@@ -59,7 +59,7 @@ valid_post = [
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tmp_type", TEMPLATE_TYPES)
|
||||
@pytest.mark.parametrize("tmp_type", list(TemplateType))
|
||||
@pytest.mark.parametrize(
|
||||
"subject,content,post_data,expected_subject,expected_content,expected_html",
|
||||
valid_post,
|
||||
@@ -93,7 +93,7 @@ def test_valid_post_template_returns_200(
|
||||
|
||||
assert resp_json["id"] == str(template.id)
|
||||
|
||||
if tmp_type == EMAIL_TYPE:
|
||||
if tmp_type == TemplateType.EMAIL:
|
||||
assert expected_subject in resp_json["subject"]
|
||||
assert resp_json["html"] == expected_html
|
||||
else:
|
||||
@@ -105,7 +105,7 @@ def test_valid_post_template_returns_200(
|
||||
def test_email_templates_not_rendered_into_content(client, sample_service):
|
||||
template = create_template(
|
||||
sample_service,
|
||||
template_type=EMAIL_TYPE,
|
||||
template_type=TemplateType.EMAIL,
|
||||
subject="Test",
|
||||
content=("Hello\n" "\r\n" "\r\n" "\n" "# This is a heading\n" "\n" "Paragraph"),
|
||||
)
|
||||
@@ -125,7 +125,7 @@ def test_email_templates_not_rendered_into_content(client, sample_service):
|
||||
assert resp_json["body"] == template.content
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tmp_type", TEMPLATE_TYPES)
|
||||
@pytest.mark.parametrize("tmp_type", list(TemplateType))
|
||||
def test_invalid_post_template_returns_400(client, sample_service, tmp_type):
|
||||
template = create_template(
|
||||
sample_service,
|
||||
|
||||
@@ -4,7 +4,7 @@ import pytest
|
||||
from flask import json
|
||||
from jsonschema.exceptions import ValidationError
|
||||
|
||||
from app.models import EMAIL_TYPE, SMS_TYPE, TEMPLATE_TYPES
|
||||
from app.models import TemplateType
|
||||
from app.schema_validation import validate
|
||||
from app.v2.template.template_schemas import (
|
||||
get_template_by_id_request,
|
||||
@@ -15,7 +15,7 @@ from app.v2.template.template_schemas import (
|
||||
|
||||
valid_json_get_response = {
|
||||
"id": str(uuid.uuid4()),
|
||||
"type": SMS_TYPE,
|
||||
"type": TemplateType.SMS,
|
||||
"created_at": "2017-01-10T18:25:43.511Z",
|
||||
"updated_at": None,
|
||||
"version": 1,
|
||||
@@ -26,7 +26,7 @@ valid_json_get_response = {
|
||||
|
||||
valid_json_get_response_with_optionals = {
|
||||
"id": str(uuid.uuid4()),
|
||||
"type": EMAIL_TYPE,
|
||||
"type": TemplateType.EMAIL,
|
||||
"created_at": "2017-01-10T18:25:43.511Z",
|
||||
"updated_at": None,
|
||||
"version": 1,
|
||||
@@ -114,7 +114,7 @@ def test_get_template_request_schema_against_invalid_args_is_invalid(
|
||||
assert error["message"] in error_message
|
||||
|
||||
|
||||
@pytest.mark.parametrize("template_type", TEMPLATE_TYPES)
|
||||
@pytest.mark.parametrize("template_type", list(TemplateType))
|
||||
@pytest.mark.parametrize(
|
||||
"response", [valid_json_get_response, valid_json_get_response_with_optionals]
|
||||
)
|
||||
@@ -149,7 +149,7 @@ def test_post_template_preview_against_invalid_args_is_invalid(args, error_messa
|
||||
assert error["message"] in error_messages
|
||||
|
||||
|
||||
@pytest.mark.parametrize("template_type", TEMPLATE_TYPES)
|
||||
@pytest.mark.parametrize("template_type", list(TemplateType))
|
||||
@pytest.mark.parametrize(
|
||||
"response", [valid_json_post_response, valid_json_post_response_with_optionals]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user