From 1b9d8252ec76b1cfc276d67c0bfeb26a675e14ba Mon Sep 17 00:00:00 2001 From: David McDonald Date: Wed, 10 Feb 2021 14:58:49 +0000 Subject: [PATCH] Rename task and function for clarity This doesn't just relate to templated letters, it's actually just checking that there are not any letters still in created that should not be. This change to the naming makes it more accurate and therefore easy to understand --- app/celery/scheduled_tasks.py | 4 ++-- app/config.py | 4 ++-- tests/app/celery/test_scheduled_tasks.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/celery/scheduled_tasks.py b/app/celery/scheduled_tasks.py index fcc5edf29..e344985f0 100644 --- a/app/celery/scheduled_tasks.py +++ b/app/celery/scheduled_tasks.py @@ -214,9 +214,9 @@ def check_precompiled_letter_state(): ) -@notify_celery.task(name='check-templated-letter-state') +@notify_celery.task(name='check-if-letters-still-in-created') @statsd(namespace="tasks") -def check_templated_letter_state(): +def check_if_letters_still_in_created(): letters = dao_old_letters_with_created_status() if len(letters) > 0: diff --git a/app/config.py b/app/config.py index 4bf384fe3..9580a92bc 100644 --- a/app/config.py +++ b/app/config.py @@ -284,8 +284,8 @@ class Config(object): # since we mark jobs as archived 'options': {'queue': QueueNames.PERIODIC}, }, - 'check-templated-letter-state': { - 'task': 'check-templated-letter-state', + 'check-if-letters-still-in-created': { + 'task': 'check-if-letters-still-in-created', 'schedule': crontab(day_of_week='mon-fri', hour=9, minute=0), 'options': {'queue': QueueNames.PERIODIC} }, diff --git a/tests/app/celery/test_scheduled_tasks.py b/tests/app/celery/test_scheduled_tasks.py index ccc5b250a..f5310ebaa 100644 --- a/tests/app/celery/test_scheduled_tasks.py +++ b/tests/app/celery/test_scheduled_tasks.py @@ -15,7 +15,7 @@ from app.celery.scheduled_tasks import ( run_scheduled_jobs, replay_created_notifications, check_precompiled_letter_state, - check_templated_letter_state, + check_if_letters_still_in_created, check_for_missing_rows_in_completed_jobs, check_for_services_with_high_failure_rates_or_sending_to_tv_numbers, switch_current_sms_provider_on_slow_delivery, @@ -356,7 +356,7 @@ def test_check_precompiled_letter_state(mocker, sample_letter_template): @freeze_time("2019-05-30 14:00:00") -def test_check_templated_letter_state_during_bst(mocker, sample_letter_template): +def test_check_if_letters_still_in_created_during_bst(mocker, sample_letter_template): mock_logger = mocker.patch('app.celery.tasks.current_app.logger.warning') mock_create_ticket = mocker.patch('app.celery.nightly_tasks.zendesk_client.create_ticket') @@ -367,7 +367,7 @@ def test_check_templated_letter_state_during_bst(mocker, sample_letter_template) create_notification(template=sample_letter_template, status='delivered', created_at=datetime(2019, 5, 28, 10, 0)) create_notification(template=sample_letter_template, created_at=datetime(2019, 5, 30, 10, 0)) - check_templated_letter_state() + check_if_letters_still_in_created() message = "2 letters were created before 17.30 yesterday and still have 'created' status. " \ "Follow runbook to resolve: " \ @@ -383,7 +383,7 @@ def test_check_templated_letter_state_during_bst(mocker, sample_letter_template) @freeze_time("2019-01-30 14:00:00") -def test_check_templated_letter_state_during_utc(mocker, sample_letter_template): +def test_check_if_letters_still_in_created_during_utc(mocker, sample_letter_template): mock_logger = mocker.patch('app.celery.tasks.current_app.logger.warning') mock_create_ticket = mocker.patch('app.celery.scheduled_tasks.zendesk_client.create_ticket') @@ -394,7 +394,7 @@ def test_check_templated_letter_state_during_utc(mocker, sample_letter_template) create_notification(template=sample_letter_template, status='delivered', created_at=datetime(2019, 1, 29, 10, 0)) create_notification(template=sample_letter_template, created_at=datetime(2019, 1, 30, 10, 0)) - check_templated_letter_state() + check_if_letters_still_in_created() message = "2 letters were created before 17.30 yesterday and still have 'created' status. " \ "Follow runbook to resolve: " \