Added a test that the message is not sent if the status of the notification is not created.

This commit is contained in:
Rebecca Law
2016-06-27 15:23:23 +01:00
parent 8435217808
commit 90e8154700

View File

@@ -4,6 +4,7 @@ from celery.exceptions import MaxRetriesExceededError
from mock import ANY, call
from notifications_utils.recipients import validate_phone_number, format_phone_number
import app
from app import statsd_client, mmg_client
from app.celery import provider_tasks
from app.celery.provider_tasks import send_sms_to_provider
@@ -219,6 +220,26 @@ def test_not_should_update_provider_stats_on_success_in_research_mode(notify_db,
assert len(updated_provider_stats) == 0
def test_should_not_send_to_provider_when_status_is_not_created(notify_db, notify_db_session,
sample_service,
mocker):
notification = sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
service=sample_service,
status='sending')
mocker.patch('app.mmg_client.send_sms')
mocker.patch('app.mmg_client.get_name', return_value="mmg")
mocker.patch('app.celery.research_mode_tasks.send_sms_response.apply_async')
send_sms_to_provider(
notification.service_id,
notification.id
)
app.mmg_client.send_sms.assert_not_called()
app.celery.research_mode_tasks.send_sms_response.apply_async.assert_not_called()
def test_statsd_updates(notify_db, notify_db_session, sample_service, sample_notification, mocker):
mocker.patch('app.statsd_client.incr')
mocker.patch('app.statsd_client.timing')