mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
make 500 error provider switches also check for recent changes
moving the logic and the test from switch provider on slow delivery to dao reduce sms provider priority
This commit is contained in:
@@ -21,7 +21,7 @@ from app.celery.scheduled_tasks import (
|
||||
from app.config import QueueNames, TaskNames
|
||||
from app.dao.jobs_dao import dao_get_job_by_id
|
||||
from app.dao.notifications_dao import dao_get_scheduled_notifications
|
||||
from app.dao.provider_details_dao import get_provider_details_by_notification_type, get_provider_details_by_identifier
|
||||
from app.dao.provider_details_dao import get_provider_details_by_identifier
|
||||
from app.models import (
|
||||
JOB_STATUS_IN_PROGRESS,
|
||||
JOB_STATUS_ERROR,
|
||||
@@ -122,21 +122,6 @@ def test_switch_current_sms_provider_on_slow_delivery_switches_when_one_provider
|
||||
mock_reduce.assert_called_once_with('firetext')
|
||||
|
||||
|
||||
@freeze_time('2017-05-01 14:00:00')
|
||||
def test_switch_current_sms_provider_on_slow_delivery_does_nothing_if_recent_changes(
|
||||
mocker,
|
||||
restore_provider_details,
|
||||
):
|
||||
mock_is_slow = mocker.patch('app.celery.scheduled_tasks.is_delivery_slow_for_providers')
|
||||
mock_reduce = mocker.patch('app.celery.scheduled_tasks.dao_reduce_sms_provider_priority')
|
||||
get_provider_details_by_identifier('mmg').updated_at = datetime(2017, 5, 1, 13, 51)
|
||||
|
||||
switch_current_sms_provider_on_slow_delivery()
|
||||
|
||||
assert mock_is_slow.called is False
|
||||
assert mock_reduce.called is False
|
||||
|
||||
|
||||
@freeze_time('2017-05-01 14:00:00')
|
||||
@pytest.mark.parametrize('is_slow_dict', [
|
||||
{'mmg': False, 'firetext': False},
|
||||
@@ -151,7 +136,6 @@ def test_switch_current_sms_provider_on_slow_delivery_does_nothing_if_no_need(
|
||||
mock_reduce = mocker.patch('app.celery.scheduled_tasks.dao_reduce_sms_provider_priority')
|
||||
get_provider_details_by_identifier('mmg').updated_at = datetime(2017, 5, 1, 13, 51)
|
||||
|
||||
|
||||
switch_current_sms_provider_on_slow_delivery()
|
||||
|
||||
assert mock_reduce.called is False
|
||||
|
||||
@@ -185,6 +185,21 @@ def test_reduce_sms_provider_priority_adds_rows_to_history_table(
|
||||
assert updated_provider_history_rows[0].priority == 90
|
||||
|
||||
|
||||
@freeze_time('2017-05-01 14:00:00')
|
||||
def test_reduce_sms_provider_priority_does_nothing_if_providers_have_recently_changed(
|
||||
mocker,
|
||||
restore_provider_details,
|
||||
):
|
||||
mock_is_slow = mocker.patch('app.celery.scheduled_tasks.is_delivery_slow_for_providers')
|
||||
mock_reduce = mocker.patch('app.celery.scheduled_tasks.dao_reduce_sms_provider_priority')
|
||||
get_provider_details_by_identifier('mmg').updated_at = datetime(2017, 5, 1, 13, 51)
|
||||
|
||||
dao_reduce_sms_provider_priority('firetext')
|
||||
|
||||
assert mock_is_slow.called is False
|
||||
assert mock_reduce.called is False
|
||||
|
||||
|
||||
@freeze_time('2018-06-28 12:00')
|
||||
def test_dao_get_provider_stats(notify_db_session):
|
||||
service_1 = create_service(service_name='1')
|
||||
|
||||
Reference in New Issue
Block a user