From aee14ed609e63955f14bd8e63402c721f03bd44c Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Thu, 25 May 2023 10:50:01 -0700 Subject: [PATCH] remove xfail --- .../test_send_notification.py | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/tests/app/service/send_notification/test_send_notification.py b/tests/app/service/send_notification/test_send_notification.py index 83122dcbc..dbd8b8d85 100644 --- a/tests/app/service/send_notification/test_send_notification.py +++ b/tests/app/service/send_notification/test_send_notification.py @@ -169,12 +169,6 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t ), '6', ), - pytest.param( - None, - ('we consider None equivalent to missing personalisation'), - '', - marks=pytest.mark.xfail - ), ]) def test_send_notification_with_placeholders_replaced_with_unusual_types( client, @@ -209,6 +203,43 @@ def test_send_notification_with_placeholders_replaced_with_unusual_types( assert response_data['subject'] == expected_subject +@pytest.mark.parametrize('personalisation, expected_body, expected_subject', [ + ( + None, + ('we consider None equivalent to missing personalisation'), + '', + ), +]) +def test_send_notification_with_placeholders_replaced_with_unusual_types_no_personalization( + client, + sample_email_template_with_placeholders, + mocker, + personalisation, + expected_body, + expected_subject, +): + 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_service_authorization_header(service_id=sample_email_template_with_placeholders.service.id) + ] + ) + + assert response.status_code == 400 + + 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: