mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
merge from main
This commit is contained in:
@@ -98,6 +98,8 @@ def expire_or_delete_invitations():
|
||||
raise
|
||||
|
||||
|
||||
# TODO THIS IS ACTUALLY DEPRECATED, WE ARE REMOVING PHONE NUMBERS FROM THE DB
|
||||
# SO THERE WILL BE NO REASON TO KEEP TRACK OF THIS COUNT
|
||||
@notify_celery.task(name="check-db-notification-fails")
|
||||
def check_db_notification_fails():
|
||||
"""
|
||||
@@ -113,6 +115,8 @@ def check_db_notification_fails():
|
||||
last_value = redis_store.get("LAST_DB_NOTIFICATION_COUNT")
|
||||
if not last_value:
|
||||
last_value = 0
|
||||
else:
|
||||
last_value = int(last_value.decode("utf-8"))
|
||||
|
||||
failed_count = dao_get_failed_notification_count()
|
||||
if failed_count > last_value:
|
||||
|
||||
@@ -72,6 +72,8 @@ def test_should_check_db_notification_fails_task_less_than_25_percent(
|
||||
mock_dao = mocker.patch(
|
||||
"app.celery.scheduled_tasks.dao_get_failed_notification_count"
|
||||
)
|
||||
mock_redis = mocker.patch("app.celery.scheduled_tasks.redis_store")
|
||||
mock_redis.get.return_value = 0
|
||||
mock_provider = mocker.patch("app.celery.scheduled_tasks.provider_to_use")
|
||||
mock_dao.return_value = 10
|
||||
check_db_notification_fails()
|
||||
@@ -88,13 +90,13 @@ def test_should_check_db_notification_fails_task_over_50_percent(
|
||||
"app.celery.scheduled_tasks.dao_get_failed_notification_count"
|
||||
)
|
||||
mock_provider = mocker.patch("app.celery.scheduled_tasks.provider_to_use")
|
||||
mock_redis = mocker.patch("app.celery.scheduled_tasks.redis_store.get")
|
||||
mock_redis = mocker.patch("app.celery.scheduled_tasks.redis_store")
|
||||
mock_dao.return_value = 5001
|
||||
mock_redis.return_value = 0
|
||||
mock_redis.get.return_value = "0".encode("utf-8")
|
||||
check_db_notification_fails()
|
||||
assert mock_provider.call_count == 1
|
||||
|
||||
mock_redis.return_value = 5001
|
||||
mock_redis.get.return_value = "5001".encode("utf-8")
|
||||
check_db_notification_fails()
|
||||
assert mock_provider.call_count == 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user