Removed logging, and make fire text only client.

This commit is contained in:
Martyn Inglis
2016-02-17 13:59:01 +00:00
parent 226459132a
commit 837c9b7cdb
3 changed files with 11 additions and 15 deletions

View File

@@ -1,8 +1,8 @@
import uuid
import pytest
from app.celery.tasks import send_sms
from app import twilio_client
from app.clients.sms.twilio import TwilioClientException
from app import firetext_client
from app.clients.sms.firetext import FiretextClientException
from app.dao import notifications_dao
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm.exc import NoResultFound
@@ -14,7 +14,7 @@ def test_should_send_template_to_correct_sms_provider_and_persist(sample_templat
"to": "+441234123123"
}
mocker.patch('app.encryption.decrypt', return_value=notification)
mocker.patch('app.twilio_client.send_sms')
mocker.patch('app.firetext_client.send_sms')
notification_id = uuid.uuid4()
@@ -23,7 +23,7 @@ def test_should_send_template_to_correct_sms_provider_and_persist(sample_templat
notification_id,
"encrypted-in-reality")
twilio_client.send_sms.assert_called_once_with("+441234123123", sample_template.content)
firetext_client.send_sms.assert_called_once_with("+441234123123", sample_template.content)
persisted_notification = notifications_dao.get_notification(sample_template.service_id, notification_id)
assert persisted_notification.id == notification_id
assert persisted_notification.to == '+441234123123'
@@ -37,7 +37,7 @@ def test_should_persist_notification_as_failed_if_sms_client_fails(sample_templa
"to": "+441234123123"
}
mocker.patch('app.encryption.decrypt', return_value=notification)
mocker.patch('app.twilio_client.send_sms', side_effect=TwilioClientException())
mocker.patch('app.firetext_client.send_sms', side_effect=FiretextClientException())
notification_id = uuid.uuid4()
@@ -46,7 +46,7 @@ def test_should_persist_notification_as_failed_if_sms_client_fails(sample_templa
notification_id,
"encrypted-in-reality")
twilio_client.send_sms.assert_called_once_with("+441234123123", sample_template.content)
firetext_client.send_sms.assert_called_once_with("+441234123123", sample_template.content)
persisted_notification = notifications_dao.get_notification(sample_template.service_id, notification_id)
assert persisted_notification.id == notification_id
assert persisted_notification.to == '+441234123123'
@@ -60,7 +60,7 @@ def test_should_not_send_sms_if_db_peristance_failed(sample_template, mocker):
"to": "+441234123123"
}
mocker.patch('app.encryption.decrypt', return_value=notification)
mocker.patch('app.twilio_client.send_sms', side_effect=TwilioClientException())
mocker.patch('app.firetext_client.send_sms', side_effect=FiretextClientException())
mocker.patch('app.db.session.add', side_effect=SQLAlchemyError())
notification_id = uuid.uuid4()
@@ -70,7 +70,7 @@ def test_should_not_send_sms_if_db_peristance_failed(sample_template, mocker):
notification_id,
"encrypted-in-reality")
twilio_client.send_sms.assert_not_called()
firetext_client.send_sms.assert_not_called()
with pytest.raises(NoResultFound) as e:
notifications_dao.get_notification(sample_template.service_id, notification_id)
assert 'No row was found for one' in str(e.value)