Merge pull request #886 from alphagov/revert-883-revert-867-bump-utils-lists-as-placeholder-values

Revert "Revert "Bump utils to allow lists as placeholder values""
This commit is contained in:
Chris Hill-Scott
2017-04-05 13:14:57 +01:00
committed by GitHub
3 changed files with 61 additions and 2 deletions

View File

@@ -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@15.0.0#egg=notifications-utils==15.0.0
git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3

View File

@@ -1018,4 +1018,4 @@ def test_dvla_letter_template(sample_letter_notification):
letter = LetterDVLATemplate(t,
sample_letter_notification.personalisation,
12345)
assert str(letter) == "140|500|001||201703230012345|23032017||||||||||||A1|A2|A3|A4|A5|A6||A_POST||||||||Template subject|Dear Sir/Madam, Hello. Yours Truly, The Government.<cr><cr>" # noqa
assert str(letter) == "140|500|001||201703230012345|||||||||||||A1|A2|A3|A4|A5|A6||A_POST|||||||||23 March 2017<cr><cr><h1>Template subject<normal><cr><cr>Dear Sir/Madam, Hello. Yours Truly, The Government.<cr><cr>" # noqa

View File

@@ -133,6 +133,65 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t
assert response_data['subject'] == 'Jo'
@pytest.mark.parametrize('personalisation, expected_body, expected_subject', [
(
['Jo', 'John', 'Josephine'],
(
'Hello \n\n'
'* Jo\n'
'* John\n'
'* Josephine\n'
'This is an email from GOV.\u200BUK'
),
'Jo, John and Josephine',
),
(
6,
(
'Hello 6\n'
'This is an email from GOV.\u200BUK'
),
'6',
),
pytest.mark.xfail((
None,
('we consider None equivalent to missing personalisation'),
'',
)),
])
def test_send_notification_with_placeholders_replaced_with_unusual_types(
client,
sample_email_template_with_placeholders,
mocker,
personalisation,
expected_body,
expected_subject,
):
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': personalisation
}
}
),
headers=[
('Content-Type', 'application/json'),
create_authorization_header(service_id=sample_email_template_with_placeholders.service.id)
]
)
assert response.status_code == 201
response_data = json.loads(response.data)['data']
assert response_data['body'] == expected_body
assert response_data['subject'] == expected_subject
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: