This commit is contained in:
Richard Chapman
2017-10-17 11:37:54 +01:00
7 changed files with 32 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ from unittest.mock import ANY, call
import pytest
from notifications_utils.recipients import validate_and_format_phone_number
from flask import current_app
from requests import HTTPError
import app
from app import mmg_client, firetext_client
@@ -235,6 +236,20 @@ def test_should_call_send_sms_response_task_if_research_mode(
assert not persisted_notification.personalisation
def test_should_leave_as_created_if_fake_callback_function_fails(sample_notification, mocker):
mocker.patch('app.delivery.send_to_providers.send_sms_response', side_effect=HTTPError)
sample_notification.key_type = KEY_TYPE_TEST
with pytest.raises(HTTPError):
send_to_providers.send_sms_to_provider(
sample_notification
)
assert sample_notification.status == 'created'
assert sample_notification.sent_at is None
assert sample_notification.sent_by is None
@pytest.mark.parametrize('research_mode,key_type', [
(True, KEY_TYPE_NORMAL),
(False, KEY_TYPE_TEST)

View File

@@ -181,7 +181,7 @@ def test_post_email_notification_returns_201(client, sample_email_template_with_
assert response.status_code == 201
resp_json = json.loads(response.get_data(as_text=True))
assert validate(resp_json, post_email_response) == resp_json
notification = Notification.query.first()
notification = Notification.query.one()
assert resp_json['id'] == str(notification.id)
assert resp_json['reference'] == reference
assert notification.reference is None