mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-14 09:12:06 -05:00
move from dao_toggle_sms_provider to dao_reduce_sms_provider_priority
This commit is contained in:
@@ -15,7 +15,7 @@ from app.dao.notifications_dao import (
|
|||||||
)
|
)
|
||||||
from app.dao.provider_details_dao import (
|
from app.dao.provider_details_dao import (
|
||||||
get_provider_details_by_notification_type,
|
get_provider_details_by_notification_type,
|
||||||
dao_toggle_sms_provider
|
dao_reduce_sms_provider_priority
|
||||||
)
|
)
|
||||||
from app.celery.research_mode_tasks import send_sms_response, send_email_response
|
from app.celery.research_mode_tasks import send_sms_response, send_email_response
|
||||||
from app.dao.templates_dao import dao_get_template_by_id
|
from app.dao.templates_dao import dao_get_template_by_id
|
||||||
@@ -66,7 +66,7 @@ def send_sms_to_provider(notification):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
notification.billable_units = template.fragment_count
|
notification.billable_units = template.fragment_count
|
||||||
dao_update_notification(notification)
|
dao_update_notification(notification)
|
||||||
dao_reduce_sms_provider_priority(provider)
|
dao_reduce_sms_provider_priority(provider.get_name())
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
notification.billable_units = template.fragment_count
|
notification.billable_units = template.fragment_count
|
||||||
|
|||||||
@@ -120,9 +120,11 @@ def test_send_sms_should_not_switch_providers_on_non_provider_failure(
|
|||||||
'app.delivery.send_to_providers.send_sms_to_provider',
|
'app.delivery.send_to_providers.send_sms_to_provider',
|
||||||
side_effect=Exception("Non Provider Exception")
|
side_effect=Exception("Non Provider Exception")
|
||||||
)
|
)
|
||||||
switch_provider_mock = mocker.patch('app.delivery.send_to_providers.dao_toggle_sms_provider')
|
mock_dao_reduce_sms_provider_priority = mocker.patch(
|
||||||
|
'app.delivery.send_to_providers.dao_reduce_sms_provider_priority'
|
||||||
|
)
|
||||||
mocker.patch('app.celery.provider_tasks.deliver_sms.retry')
|
mocker.patch('app.celery.provider_tasks.deliver_sms.retry')
|
||||||
|
|
||||||
deliver_sms(sample_notification.id)
|
deliver_sms(sample_notification.id)
|
||||||
|
|
||||||
assert switch_provider_mock.called is False
|
assert mock_dao_reduce_sms_provider_priority.called is False
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ def test_should_set_notification_billable_units_if_sending_to_provider_fails(
|
|||||||
mocker,
|
mocker,
|
||||||
):
|
):
|
||||||
mocker.patch('app.mmg_client.send_sms', side_effect=Exception())
|
mocker.patch('app.mmg_client.send_sms', side_effect=Exception())
|
||||||
mock_toggle_provider = mocker.patch('app.delivery.send_to_providers.dao_toggle_sms_provider')
|
mocker.patch('app.delivery.send_to_providers.dao_reduce_sms_provider_priority')
|
||||||
|
|
||||||
sample_notification.billable_units = 0
|
sample_notification.billable_units = 0
|
||||||
assert sample_notification.sent_by is None
|
assert sample_notification.sent_by is None
|
||||||
@@ -562,7 +562,6 @@ def test_should_set_notification_billable_units_if_sending_to_provider_fails(
|
|||||||
send_to_providers.send_sms_to_provider(sample_notification)
|
send_to_providers.send_sms_to_provider(sample_notification)
|
||||||
|
|
||||||
assert sample_notification.billable_units == 1
|
assert sample_notification.billable_units == 1
|
||||||
assert mock_toggle_provider.called
|
|
||||||
|
|
||||||
|
|
||||||
def test_should_send_sms_to_international_providers(
|
def test_should_send_sms_to_international_providers(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from tests import create_authorization_header
|
|||||||
from tests.app.db import create_ft_billing
|
from tests.app.db import create_ft_billing
|
||||||
|
|
||||||
|
|
||||||
def test_get_provider_details_returns_all_providers(admin_request, db_session):
|
def test_get_provider_details_returns_all_providers(admin_request, notify_db_session):
|
||||||
json_resp = admin_request.get('provider_details.get_providers')['provider_details']
|
json_resp = admin_request.get('provider_details.get_providers')['provider_details']
|
||||||
|
|
||||||
assert len(json_resp) == 4
|
assert len(json_resp) == 4
|
||||||
|
|||||||
Reference in New Issue
Block a user