code review feedback

This commit is contained in:
Kenneth Kehl
2023-08-15 14:50:41 -07:00
parent c5008da8df
commit f2f0e5a0f1
10 changed files with 2 additions and 165 deletions

View File

@@ -325,10 +325,6 @@ def test_delete_notifications_task_calls_task_for_services_that_have_sent_notifi
])
def delete_notifications_by_service_and_type(id, param, param1):
pass
def test_cleanup_unfinished_jobs(mocker):
mock_s3 = mocker.patch('app.celery.nightly_tasks.remove_csv_object')
mock_dao_archive = mocker.patch('app.celery.nightly_tasks.dao_archive_job')

View File

@@ -42,24 +42,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-tasks", countdown=0)
def test_send_sms_should_not_switch_providers_on_non_provider_failure(
sample_notification,
mocker
):
mocker.patch(
'app.delivery.send_to_providers.send_sms_to_provider',
side_effect=Exception("Non Provider Exception")
)
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')
deliver_sms(sample_notification.id)
assert mock_dao_reduce_sms_provider_priority.called is False
def test_should_retry_and_log_warning_if_SmsClientResponseException_for_deliver_sms_task(sample_notification, mocker):
mocker.patch(
'app.delivery.send_to_providers.send_sms_to_provider',

View File

@@ -60,10 +60,6 @@ def test_should_raise_for_status(perf_client):
perf_client.send_stats_to_performance_platform({'dataType': 'foo'})
def generate_payload_id(payload, param):
pass
def test_generate_payload_id():
payload = {'_timestamp': '2023-01-01 00:00:00', 'service': 'my_service', 'group_name': 'group_name',
'dataType': 'dataType', 'period': 'period'}

View File

@@ -6,16 +6,6 @@ from app.dao.email_branding_dao import (
from app.models import EmailBranding
from tests.app.db import create_email_branding
# def test_get_email_branding_options_gets_all_email_branding(notify_db_session):
# email_branding_1 = create_email_branding(name='test_email_branding_1')
# email_branding_2 = create_email_branding(name='test_email_branding_2')
#
# email_branding = dao_get_email_branding_options()
#
# assert len(email_branding) == 2
# assert email_branding_1 == email_branding[0]
# assert email_branding_2 == email_branding[1]
def test_get_email_branding_by_id_gets_correct_email_branding(notify_db_session):
email_branding = create_email_branding()

View File

@@ -8,9 +8,7 @@ from app import notification_provider_clients
from app.dao.provider_details_dao import (
_adjust_provider_priority,
_get_sms_providers_for_update,
dao_adjust_provider_priority_back_to_resting_points,
dao_get_provider_stats,
dao_reduce_sms_provider_priority,
dao_update_provider_details,
get_alternative_sms_provider,
get_provider_details_by_identifier,
@@ -196,57 +194,6 @@ def test_get_sms_providers_for_update_returns_nothing_if_recent_updates(restore_
assert not resp
def test_reduce_sms_provider_priority_does_nothing_if_providers_have_recently_changed(
mocker,
restore_provider_details,
):
mock_get_providers = mocker.patch('app.dao.provider_details_dao._get_sms_providers_for_update', return_value=[])
mock_adjust = mocker.patch('app.dao.provider_details_dao._adjust_provider_priority')
dao_reduce_sms_provider_priority('sns', time_threshold=timedelta(minutes=5))
mock_get_providers.assert_called_once_with(timedelta(minutes=5))
assert mock_adjust.called is False
def test_reduce_sms_provider_priority_does_nothing_if_there_is_only_one_active_provider(
mocker,
restore_provider_details,
):
mock_adjust = mocker.patch('app.dao.provider_details_dao._adjust_provider_priority')
dao_reduce_sms_provider_priority('sns', time_threshold=timedelta(minutes=5))
assert mock_adjust.called is False
def test_adjust_provider_priority_back_to_resting_points_does_nothing_if_theyre_already_at_right_values(
restore_provider_details,
mocker,
):
sns = get_provider_details_by_identifier('sns')
sns.priority = 100
mock_adjust = mocker.patch('app.dao.provider_details_dao._adjust_provider_priority')
mocker.patch('app.dao.provider_details_dao._get_sms_providers_for_update', return_value=[sns])
dao_adjust_provider_priority_back_to_resting_points()
assert mock_adjust.called is False
def test_adjust_provider_priority_back_to_resting_points_does_nothing_if_no_providers_to_update(
restore_provider_details,
mocker,
):
mock_adjust = mocker.patch('app.dao.provider_details_dao._adjust_provider_priority')
mocker.patch('app.dao.provider_details_dao._get_sms_providers_for_update', return_value=[])
dao_adjust_provider_priority_back_to_resting_points()
assert mock_adjust.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')

View File

@@ -1,7 +1,7 @@
import json
import uuid
from collections import namedtuple
from datetime import datetime, timedelta
from datetime import datetime
from unittest.mock import ANY
import pytest
@@ -595,7 +595,6 @@ def test_should_set_notification_billable_units_and_reduces_provider_priority_if
mocker,
):
mocker.patch('app.aws_sns_client.send_sms', side_effect=Exception())
mock_reduce = mocker.patch('app.delivery.send_to_providers.dao_reduce_sms_provider_priority')
sample_notification.billable_units = 0
assert sample_notification.sent_by is None
@@ -608,7 +607,6 @@ def test_should_set_notification_billable_units_and_reduces_provider_priority_if
assert 1 == 1
assert sample_notification.billable_units == 1
mock_reduce.assert_called_once_with('sns', time_threshold=timedelta(minutes=1))
def test_should_send_sms_to_international_providers(