From c9882e2f9cd240936ed9b4d5a0421c18afa18ebc Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 9 Apr 2018 16:30:24 +0100 Subject: [PATCH] Bump utils to improve plain text email formatting Brings in: - [x] https://github.com/alphagov/notifications-utils/pull/438 - [x] https://github.com/alphagov/notifications-utils/pull/450 - [x] https://github.com/alphagov/notifications-utils/pull/454 Changes: - https://github.com/alphagov/notifications-utils/compare/25.3.0...26.2.0 --- app/utils.py | 4 ++-- requirements.txt | 2 +- tests/app/delivery/test_send_to_providers.py | 2 +- tests/app/notifications/rest/test_send_notification.py | 6 +++--- tests/app/notifications/test_rest.py | 2 +- tests/app/v2/notifications/test_get_notifications.py | 2 +- tests/app/v2/notifications/test_post_notifications.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/utils.py b/app/utils.py index 1646639c6..f07be8559 100644 --- a/app/utils.py +++ b/app/utils.py @@ -3,7 +3,7 @@ from datetime import datetime, timedelta import pytz from flask import url_for from sqlalchemy import func -from notifications_utils.template import SMSMessageTemplate, PlainTextEmailTemplate +from notifications_utils.template import SMSMessageTemplate, WithSubjectTemplate local_timezone = pytz.timezone("Europe/London") @@ -30,7 +30,7 @@ def url_with_token(data, url, config, base_url=None): def get_template_instance(template, values): from app.models import SMS_TYPE, EMAIL_TYPE, LETTER_TYPE return { - SMS_TYPE: SMSMessageTemplate, EMAIL_TYPE: PlainTextEmailTemplate, LETTER_TYPE: PlainTextEmailTemplate + SMS_TYPE: SMSMessageTemplate, EMAIL_TYPE: WithSubjectTemplate, LETTER_TYPE: WithSubjectTemplate }[template['template_type']](template, values) diff --git a/requirements.txt b/requirements.txt index e3e0cc252..a1b99acc1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,6 +23,6 @@ notifications-python-client==4.8.1 # PaaS awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@25.3.0#egg=notifications-utils==25.3.0 +git+https://github.com/alphagov/notifications-utils.git@26.2.0#egg=notifications-utils==26.2.0 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 diff --git a/tests/app/delivery/test_send_to_providers.py b/tests/app/delivery/test_send_to_providers.py index 4befcf7c1..57ed3b50c 100644 --- a/tests/app/delivery/test_send_to_providers.py +++ b/tests/app/delivery/test_send_to_providers.py @@ -117,7 +117,7 @@ def test_should_send_personalised_template_to_correct_email_provider_and_persist '"Sample service" ', 'jo.smith@example.com', 'Jo some HTML', - body='Hello Jo\nThis is an email from GOV.\u200bUK with some HTML', + body='Hello Jo\nThis is an email from GOV.\u200bUK with some HTML\n', html_body=ANY, reply_to_address=None ) diff --git a/tests/app/notifications/rest/test_send_notification.py b/tests/app/notifications/rest/test_send_notification.py index 480455e75..9eda1cdf3 100644 --- a/tests/app/notifications/rest/test_send_notification.py +++ b/tests/app/notifications/rest/test_send_notification.py @@ -136,7 +136,7 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t queue="send-email-tasks" ) assert response.status_code == 201 - assert response_data['body'] == u'Hello Jo\nThis is an email from GOV.\u200BUK' + assert response_data['body'] == u'Hello Jo\nThis is an email from GOV.UK' assert response_data['subject'] == 'Jo' @@ -148,7 +148,7 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t '* Jo\n' '* John\n' '* Josephine\n' - 'This is an email from GOV.\u200BUK' + 'This is an email from GOV.UK' ), 'Jo, John and Josephine', ), @@ -156,7 +156,7 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t 6, ( 'Hello 6\n' - 'This is an email from GOV.\u200BUK' + 'This is an email from GOV.UK' ), '6', ), diff --git a/tests/app/notifications/test_rest.py b/tests/app/notifications/test_rest.py index f35e262c1..0c9051d90 100644 --- a/tests/app/notifications/test_rest.py +++ b/tests/app/notifications/test_rest.py @@ -579,7 +579,7 @@ def test_get_notification_by_id_returns_merged_template_content_for_email( notification = json.loads(response.get_data(as_text=True))['data']['notification'] assert response.status_code == 200 - assert notification['body'] == 'Hello world\nThis is an email from GOV.\u200BUK' + assert notification['body'] == 'Hello world\nThis is an email from GOV.UK' assert notification['subject'] == 'world' assert notification['content_char_count'] is None diff --git a/tests/app/v2/notifications/test_get_notifications.py b/tests/app/v2/notifications/test_get_notifications.py index fcfd22e15..52e5a5bed 100644 --- a/tests/app/v2/notifications/test_get_notifications.py +++ b/tests/app/v2/notifications/test_get_notifications.py @@ -120,7 +120,7 @@ def test_get_notification_by_id_with_placeholders_returns_200( 'status': '{}'.format(sample_notification.status), 'template': expected_template_response, 'created_at': sample_notification.created_at.strftime(DATETIME_FORMAT), - 'body': "Hello Bob\nThis is an email from GOV.\u200bUK", + 'body': "Hello Bob\nThis is an email from GOV.UK", "subject": "Bob", 'sent_at': sample_notification.sent_at, 'completed_at': sample_notification.completed_at(), diff --git a/tests/app/v2/notifications/test_post_notifications.py b/tests/app/v2/notifications/test_post_notifications.py index 9c2927e76..d49622788 100644 --- a/tests/app/v2/notifications/test_post_notifications.py +++ b/tests/app/v2/notifications/test_post_notifications.py @@ -313,7 +313,7 @@ def test_post_email_notification_returns_201(client, sample_email_template_with_ assert notification.reference is None assert notification.reply_to_text is None assert resp_json['content']['body'] == sample_email_template_with_placeholders.content \ - .replace('((name))', 'Bob').replace('GOV.UK', u'GOV.\u200bUK') + .replace('((name))', 'Bob') assert resp_json['content']['subject'] == sample_email_template_with_placeholders.subject \ .replace('((name))', 'Bob') assert resp_json['content']['from_email'] == "{}@{}".format(