diff --git a/app/notifications/rest.py b/app/notifications/rest.py index 4647cfd8b..202ebc653 100644 --- a/app/notifications/rest.py +++ b/app/notifications/rest.py @@ -260,9 +260,10 @@ def send_notification(notification_type): status_code=400 ) + notification_id = create_uuid() + notification.update({"template_version": template.version}) + if not _simulated_recipient(notification['to'], notification_type): - notification_id = create_uuid() - notification.update({"template_version": template.version}) persist_notification( service, notification_id, @@ -273,16 +274,12 @@ def send_notification(notification_type): api_user.key_type ) - return jsonify( - data=get_notification_return_data( - notification_id, - notification, - template_object) - ), 201 - else: - return jsonify( - data=_get_simulated_recipient_response_data(template_object) - ), 200 + return jsonify( + data=get_notification_return_data( + notification_id, + notification, + template_object) + ), 201 def get_notification_return_data(notification_id, notification, template): @@ -314,18 +311,6 @@ def _simulated_recipient(to_address, notification_type): else to_address in current_app.config['SIMULATED_EMAIL_ADDRESSES']) -def _get_simulated_recipient_response_data(template_object): - response_data = { - 'body': template_object.replaced, - 'template_version': template_object._template['version'] - } - - if template_object._template['template_type'] == 'email': - response_data.update({'subject': template_object.replaced_subject}) - - return response_data - - def persist_notification( service, notification_id, diff --git a/tests/app/notifications/rest/test_send_notification.py b/tests/app/notifications/rest/test_send_notification.py index 97cd8ec53..0d8ad94c5 100644 --- a/tests/app/notifications/rest/test_send_notification.py +++ b/tests/app/notifications/rest/test_send_notification.py @@ -963,7 +963,7 @@ def test_should_not_send_email_if_simulated_email_address(client, to_email, samp data=json.dumps(data), headers=[('Content-Type', 'application/json'), auth_header]) - assert response.status_code == 200 + assert response.status_code == 201 apply_async.assert_not_called() @@ -987,5 +987,5 @@ def test_should_not_send_sms_if_simulated_sms_number(client, to_sms, sample_temp data=json.dumps(data), headers=[('Content-Type', 'application/json'), auth_header]) - assert response.status_code == 200 + assert response.status_code == 201 apply_async.assert_not_called()