From 7fa33a52a9b50016be9c06eccd0bc661e18f8c34 Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Wed, 13 Apr 2016 12:49:38 +0100 Subject: [PATCH] Fixed bug with deleting the 'delivered' notifications. --- app/celery/tasks.py | 2 +- tests/app/celery/test_tasks.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 5b67e3b3c..8a70a9380 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -70,7 +70,7 @@ def delete_verify_codes(): def delete_successful_notifications(): try: start = datetime.utcnow() - deleted = delete_notifications_created_more_than_a_week_ago('sending') + deleted = delete_notifications_created_more_than_a_week_ago('delivered') current_app.logger.info( "Delete job started {} finished {} deleted {} successful notifications".format( start, diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index 04d32a5f8..1da767320 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -45,14 +45,16 @@ mmg_error = {'Error': '40', 'Description': 'error'} def test_should_call_delete_notifications_more_than_week_in_task(notify_api, mocker): - mocker.patch('app.celery.tasks.delete_notifications_created_more_than_a_week_ago') + mocked = mocker.patch('app.celery.tasks.delete_notifications_created_more_than_a_week_ago') delete_successful_notifications() + assert mocked.assert_called_with('delivered') assert tasks.delete_notifications_created_more_than_a_week_ago.call_count == 1 def test_should_call_delete_notifications_more_than_week_in_task(notify_api, mocker): - mocker.patch('app.celery.tasks.delete_notifications_created_more_than_a_week_ago') + mocked = mocker.patch('app.celery.tasks.delete_notifications_created_more_than_a_week_ago') delete_failed_notifications() + mocked.assert_called_with('failed') assert tasks.delete_notifications_created_more_than_a_week_ago.call_count == 1