mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Added a test that the message is not sent if the status of the notification is not created.
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user