mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Added letter preview
This commit is contained in:
@@ -3,7 +3,7 @@ from datetime import datetime, timedelta
|
|||||||
import pytz
|
import pytz
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from notifications_utils.template import SMSMessageTemplate, PlainTextEmailTemplate
|
from notifications_utils.template import SMSMessageTemplate, PlainTextEmailTemplate, LetterPreviewTemplate
|
||||||
|
|
||||||
|
|
||||||
def pagination_links(pagination, endpoint, **kwargs):
|
def pagination_links(pagination, endpoint, **kwargs):
|
||||||
@@ -26,9 +26,9 @@ def url_with_token(data, url, config):
|
|||||||
|
|
||||||
|
|
||||||
def get_template_instance(template, values):
|
def get_template_instance(template, values):
|
||||||
from app.models import SMS_TYPE, EMAIL_TYPE
|
from app.models import SMS_TYPE, EMAIL_TYPE, LETTER_TYPE
|
||||||
return {
|
return {
|
||||||
SMS_TYPE: SMSMessageTemplate, EMAIL_TYPE: PlainTextEmailTemplate
|
SMS_TYPE: SMSMessageTemplate, EMAIL_TYPE: PlainTextEmailTemplate, LETTER_TYPE: LetterPreviewTemplate
|
||||||
}[template['template_type']](template, values)
|
}[template['template_type']](template, values)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import uuid
|
|||||||
|
|
||||||
from flask import json
|
from flask import json
|
||||||
|
|
||||||
from app.models import EMAIL_TYPE, SMS_TYPE, LETTER_TYPE
|
from app.models import TEMPLATE_TYPES
|
||||||
from tests import create_authorization_header
|
from tests import create_authorization_header
|
||||||
from tests.app.db import create_template
|
from tests.app.db import create_template
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ valid_data = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("tmp_type", [EMAIL_TYPE, SMS_TYPE])
|
@pytest.mark.parametrize("tmp_type", TEMPLATE_TYPES)
|
||||||
def test_valid_post_template_returns_200(client, sample_service, tmp_type):
|
def test_valid_post_template_returns_200(client, sample_service, tmp_type):
|
||||||
template = create_template(
|
template = create_template(
|
||||||
sample_service,
|
sample_service,
|
||||||
@@ -35,7 +35,7 @@ def test_valid_post_template_returns_200(client, sample_service, tmp_type):
|
|||||||
assert 'Dear {}'.format(valid_data['personalisation']['Name']) in resp_json['content']['body']
|
assert 'Dear {}'.format(valid_data['personalisation']['Name']) in resp_json['content']['body']
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("tmp_type", [EMAIL_TYPE, SMS_TYPE])
|
@pytest.mark.parametrize("tmp_type", TEMPLATE_TYPES)
|
||||||
def test_invalid_post_template_returns_400(client, sample_service, tmp_type):
|
def test_invalid_post_template_returns_400(client, sample_service, tmp_type):
|
||||||
template = create_template(
|
template = create_template(
|
||||||
sample_service,
|
sample_service,
|
||||||
|
|||||||
Reference in New Issue
Block a user