mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-10 20:51:14 -05:00
remove unused former send_sms_to_provider and send_sms_to_email functions
they were superceded by deliver_sms and deliver_email in the same file 3 wks ago
This commit is contained in:
@@ -3,7 +3,7 @@ from notifications_utils.recipients import InvalidEmailError
|
||||
|
||||
import app
|
||||
from app.celery import provider_tasks
|
||||
from app.celery.provider_tasks import send_sms_to_provider, send_email_to_provider, deliver_sms, deliver_email
|
||||
from app.celery.provider_tasks import deliver_sms, deliver_email
|
||||
from app.clients.email import EmailClientException
|
||||
from app.models import Notification
|
||||
|
||||
@@ -68,32 +68,6 @@ def test_should_add_to_retry_queue_if_notification_not_found_in_deliver_sms_task
|
||||
app.celery.provider_tasks.deliver_sms.retry.assert_called_with(queue="retry", countdown=10)
|
||||
|
||||
|
||||
def test_should_call_send_sms_to_provider_from_send_sms_to_provider_task(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_notification,
|
||||
mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_sms_to_provider')
|
||||
|
||||
send_sms_to_provider(sample_notification.service_id, sample_notification.id)
|
||||
app.delivery.send_to_providers.send_sms_to_provider.assert_called_with(sample_notification)
|
||||
|
||||
|
||||
def test_should_add_to_retry_queue_if_notification_not_found_in_send_sms_to_provider_task(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_sms_to_provider')
|
||||
mocker.patch('app.celery.provider_tasks.send_sms_to_provider.retry')
|
||||
|
||||
notification_id = app.create_uuid()
|
||||
service_id = app.create_uuid()
|
||||
|
||||
send_sms_to_provider(service_id, notification_id)
|
||||
app.delivery.send_to_providers.send_sms_to_provider.assert_not_called()
|
||||
app.celery.provider_tasks.send_sms_to_provider.retry.assert_called_with(queue="retry", countdown=10)
|
||||
|
||||
|
||||
def test_should_call_send_email_to_provider_from_deliver_email_task(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
@@ -105,10 +79,7 @@ def test_should_call_send_email_to_provider_from_deliver_email_task(
|
||||
app.delivery.send_to_providers.send_email_to_provider.assert_called_with(sample_notification)
|
||||
|
||||
|
||||
def test_should_add_to_retry_queue_if_notification_not_found_in_deliver_email_task(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
mocker):
|
||||
def test_should_add_to_retry_queue_if_notification_not_found_in_deliver_email_task(mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_email_to_provider')
|
||||
mocker.patch('app.celery.provider_tasks.deliver_email.retry')
|
||||
|
||||
@@ -119,119 +90,28 @@ def test_should_add_to_retry_queue_if_notification_not_found_in_deliver_email_ta
|
||||
app.celery.provider_tasks.deliver_email.retry.assert_called_with(queue="retry", countdown=10)
|
||||
|
||||
|
||||
def test_should_call_send_email_to_provider_from_email_task(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_notification,
|
||||
mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_email_to_provider')
|
||||
|
||||
send_email_to_provider(sample_notification.service_id, sample_notification.id)
|
||||
app.delivery.send_to_providers.send_email_to_provider.assert_called_with(sample_notification)
|
||||
|
||||
|
||||
def test_should_add_to_retry_queue_if_notification_not_found_in_send_email_to_provider_task(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_email_to_provider')
|
||||
mocker.patch('app.celery.provider_tasks.send_email_to_provider.retry')
|
||||
|
||||
notification_id = app.create_uuid()
|
||||
service_id = app.create_uuid()
|
||||
|
||||
send_email_to_provider(service_id, notification_id)
|
||||
app.delivery.send_to_providers.send_email_to_provider.assert_not_called()
|
||||
app.celery.provider_tasks.send_email_to_provider.retry.assert_called_with(queue="retry", countdown=10)
|
||||
|
||||
|
||||
# DO THESE FOR THE 4 TYPES OF TASK
|
||||
|
||||
def test_should_go_into_technical_error_if_exceeds_retries_on_send_sms_to_provider_task(
|
||||
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='created')
|
||||
|
||||
mocker.patch('app.delivery.send_to_providers.send_sms_to_provider', side_effect=Exception("EXPECTED"))
|
||||
mocker.patch('app.celery.provider_tasks.send_sms_to_provider.retry', side_effect=MaxRetriesExceededError())
|
||||
|
||||
send_sms_to_provider(
|
||||
notification.service_id,
|
||||
notification.id
|
||||
)
|
||||
|
||||
provider_tasks.send_sms_to_provider.retry.assert_called_with(queue='retry', countdown=10)
|
||||
|
||||
db_notification = Notification.query.filter_by(id=notification.id).one()
|
||||
assert db_notification.status == 'technical-failure'
|
||||
|
||||
|
||||
def test_should_go_into_technical_error_if_exceeds_retries_on_deliver_sms_task(
|
||||
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='created')
|
||||
|
||||
def test_should_go_into_technical_error_if_exceeds_retries_on_deliver_sms_task(sample_notification, mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_sms_to_provider', side_effect=Exception("EXPECTED"))
|
||||
mocker.patch('app.celery.provider_tasks.deliver_sms.retry', side_effect=MaxRetriesExceededError())
|
||||
|
||||
deliver_sms(
|
||||
notification.id
|
||||
)
|
||||
deliver_sms(sample_notification.id)
|
||||
|
||||
provider_tasks.deliver_sms.retry.assert_called_with(queue='retry', countdown=10)
|
||||
|
||||
db_notification = Notification.query.filter_by(id=notification.id).one()
|
||||
assert db_notification.status == 'technical-failure'
|
||||
assert sample_notification.status == 'technical-failure'
|
||||
|
||||
|
||||
def test_send_email_to_provider_should_go_into_technical_error_if_exceeds_retries_on_send_email_to_provider_task(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_service,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
notification = sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
service=sample_service, status='created', template=sample_email_template)
|
||||
|
||||
mocker.patch('app.aws_ses_client.send_email', side_effect=EmailClientException("EXPECTED"))
|
||||
mocker.patch('app.celery.provider_tasks.send_email_to_provider.retry', side_effect=MaxRetriesExceededError())
|
||||
|
||||
send_email_to_provider(
|
||||
notification.service_id,
|
||||
notification.id
|
||||
)
|
||||
|
||||
provider_tasks.send_email_to_provider.retry.assert_called_with(queue='retry', countdown=10)
|
||||
|
||||
db_notification = Notification.query.filter_by(id=notification.id).one()
|
||||
assert db_notification.status == 'technical-failure'
|
||||
|
||||
|
||||
def test_should_go_into_technical_error_if_exceeds_retries_on_deliver_email_task(
|
||||
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='created')
|
||||
|
||||
def test_should_go_into_technical_error_if_exceeds_retries_on_deliver_email_task(sample_notification, mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_email_to_provider', side_effect=Exception("EXPECTED"))
|
||||
mocker.patch('app.celery.provider_tasks.deliver_email.retry', side_effect=MaxRetriesExceededError())
|
||||
|
||||
deliver_email(
|
||||
notification.id
|
||||
)
|
||||
deliver_email(sample_notification.id)
|
||||
|
||||
provider_tasks.deliver_email.retry.assert_called_with(queue='retry', countdown=10)
|
||||
assert sample_notification.status == 'technical-failure'
|
||||
|
||||
db_notification = Notification.query.filter_by(id=notification.id).one()
|
||||
assert db_notification.status == 'technical-failure'
|
||||
|
||||
def test_should_technical_error_and_not_retry_if_invalid_email(sample_notification, mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_email_to_provider', side_effect=InvalidEmailError('bad email'))
|
||||
|
||||
@@ -634,7 +634,7 @@ def test_should_not_send_sms_if_team_key_and_recipient_not_in_team(notify_db, no
|
||||
assert "07890 300000" not in team_members
|
||||
|
||||
notification = _notification_json(template, "07700 900849")
|
||||
mocker.patch('app.celery.provider_tasks.send_sms_to_provider.apply_async')
|
||||
mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
|
||||
|
||||
notification_id = uuid.uuid4()
|
||||
send_sms(
|
||||
@@ -643,7 +643,7 @@ def test_should_not_send_sms_if_team_key_and_recipient_not_in_team(notify_db, no
|
||||
encryption.encrypt(notification),
|
||||
datetime.utcnow().strftime(DATETIME_FORMAT)
|
||||
)
|
||||
assert provider_tasks.send_sms_to_provider.apply_async.called is False
|
||||
assert provider_tasks.deliver_sms.apply_async.called is False
|
||||
with pytest.raises(NoResultFound):
|
||||
Notification.query.filter_by(id=notification_id).one()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user