diff --git a/app/celery/reporting_tasks.py b/app/celery/reporting_tasks.py index 8231e0613..d88c62deb 100644 --- a/app/celery/reporting_tasks.py +++ b/app/celery/reporting_tasks.py @@ -67,14 +67,9 @@ def create_nightly_billing_for_day(process_day): @notify_celery.task(name="create-nightly-notification-status") @cronitor("create-nightly-notification-status") @statsd(namespace="tasks") -def create_nightly_notification_status(day_start=None): - # day_start is a datetime.date() object. e.g. - # 4 days of data counting back from day_start is consolidated - if day_start is None: - day_start = convert_utc_to_bst(datetime.utcnow()).date() - timedelta(days=1) - else: - # When calling the task its a string in the format of "YYYY-MM-DD" - day_start = datetime.strptime(day_start, "%Y-%m-%d").date() +def create_nightly_notification_status(): + day_start = convert_utc_to_bst(datetime.utcnow()).date() - timedelta(days=1) + for i in range(0, 4): process_day = day_start - timedelta(days=i) for notification_type in [SMS_TYPE, EMAIL_TYPE, LETTER_TYPE]: diff --git a/tests/app/celery/test_reporting_tasks.py b/tests/app/celery/test_reporting_tasks.py index e8d86d1a0..f6fb40a3b 100644 --- a/tests/app/celery/test_reporting_tasks.py +++ b/tests/app/celery/test_reporting_tasks.py @@ -50,16 +50,15 @@ def test_create_nightly_billing_triggers_tasks_for_days(notify_api, mocker, day_ @freeze_time('2019-08-01') -@pytest.mark.parametrize('day_start, expected_kwargs', [ - (None, ['2019-07-31', '2019-07-30', '2019-07-29', '2019-07-28']), - ('2019-07-21', ['2019-07-21', '2019-07-20', '2019-07-19', '2019-07-18']), -]) -def test_create_nightly_notification_status_triggers_tasks_for_days(notify_api, mocker, day_start, expected_kwargs): +def test_create_nightly_notification_status_triggers_tasks_for_days(notify_api, mocker): mock_celery = mocker.patch('app.celery.reporting_tasks.create_nightly_notification_status_for_day') - create_nightly_notification_status(day_start) + create_nightly_notification_status() assert mock_celery.apply_async.call_count == 4 * 3 # four days, three notification types - for process_date, notification_type in itertools.product(expected_kwargs, ['sms', 'email', 'letter']): + for process_date, notification_type in itertools.product( + ['2019-07-31', '2019-07-30', '2019-07-29', '2019-07-28'], + ['sms', 'email', 'letter'] + ): mock_celery.apply_async.assert_any_call( kwargs={'process_day': process_date, 'notification_type': notification_type}, queue=QueueNames.REPORTING