From 585ef8e66a4203ca978b9d0c4f36d76db44ebd11 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 24 Mar 2017 12:46:01 +0000 Subject: [PATCH 1/2] Bump utils to allow lists as placeholder values Brings in: - [ ] https://github.com/alphagov/notifications-utils/pull/128 Also adds a test to make sure that passing a dictionary as a value in the `personalisation` argument works. --- requirements.txt | 2 +- .../rest/test_send_notification.py | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 73cf5b94b..dc7250dd3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,6 +29,6 @@ notifications-python-client>=3.1,<3.2 awscli>=1.11,<1.12 awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@13.9.6#egg=notifications-utils==13.9.6 +git+https://github.com/alphagov/notifications-utils.git@14.0.0#egg=notifications-utils==14.0.0 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 diff --git a/tests/app/notifications/rest/test_send_notification.py b/tests/app/notifications/rest/test_send_notification.py index be2a139ac..cde289b58 100644 --- a/tests/app/notifications/rest/test_send_notification.py +++ b/tests/app/notifications/rest/test_send_notification.py @@ -133,6 +133,42 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t assert response_data['subject'] == 'Jo' +def test_send_notification_with_placeholders_replaced_with_list( + client, + sample_email_template_with_placeholders, + mocker +): + mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async') + + response = client.post( + path='/notifications/email', + data=json.dumps( + { + 'to': 'ok@ok.com', + 'template': str(sample_email_template_with_placeholders.id), + 'personalisation': { + 'name': ['Jo', 'John', 'Josephine'] + } + } + ), + headers=[ + ('Content-Type', 'application/json'), + create_authorization_header(service_id=sample_email_template_with_placeholders.service.id) + ] + ) + + response_data = json.loads(response.data)['data'] + assert response.status_code == 201 + assert response_data['body'] == ( + 'Hello \n\n' + '* Jo\n' + '* John\n' + '* Josephine\n' + 'This is an email from GOV.\u200BUK' + ) + assert response_data['subject'] == 'Jo, John and Josephine' + + def test_should_not_send_notification_for_archived_template(notify_api, sample_template): with notify_api.test_request_context(): with notify_api.test_client() as client: From b19486ec990ed9dd7e1dfc570d08ba9662452521 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 3 Apr 2017 17:22:34 +0100 Subject: [PATCH 2/2] Include fixes for heading spacing Brings in - [x] https://github.com/alphagov/notifications-utils/pull/134 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index dc7250dd3..783686de9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,6 +29,6 @@ notifications-python-client>=3.1,<3.2 awscli>=1.11,<1.12 awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@14.0.0#egg=notifications-utils==14.0.0 +git+https://github.com/alphagov/notifications-utils.git@14.0.1#egg=notifications-utils==14.0.1 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3