mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
remove day_start from create nightly notification status
it makes less sense once we introduce different start dates for letters and emails. Also, we never use it, since we just call the day tasks ourselves from commands.py
This commit is contained in:
@@ -67,14 +67,9 @@ def create_nightly_billing_for_day(process_day):
|
|||||||
@notify_celery.task(name="create-nightly-notification-status")
|
@notify_celery.task(name="create-nightly-notification-status")
|
||||||
@cronitor("create-nightly-notification-status")
|
@cronitor("create-nightly-notification-status")
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def create_nightly_notification_status(day_start=None):
|
def create_nightly_notification_status():
|
||||||
# day_start is a datetime.date() object. e.g.
|
day_start = convert_utc_to_bst(datetime.utcnow()).date() - timedelta(days=1)
|
||||||
# 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()
|
|
||||||
for i in range(0, 4):
|
for i in range(0, 4):
|
||||||
process_day = day_start - timedelta(days=i)
|
process_day = day_start - timedelta(days=i)
|
||||||
for notification_type in [SMS_TYPE, EMAIL_TYPE, LETTER_TYPE]:
|
for notification_type in [SMS_TYPE, EMAIL_TYPE, LETTER_TYPE]:
|
||||||
|
|||||||
@@ -50,16 +50,15 @@ def test_create_nightly_billing_triggers_tasks_for_days(notify_api, mocker, day_
|
|||||||
|
|
||||||
|
|
||||||
@freeze_time('2019-08-01')
|
@freeze_time('2019-08-01')
|
||||||
@pytest.mark.parametrize('day_start, expected_kwargs', [
|
def test_create_nightly_notification_status_triggers_tasks_for_days(notify_api, mocker):
|
||||||
(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):
|
|
||||||
mock_celery = mocker.patch('app.celery.reporting_tasks.create_nightly_notification_status_for_day')
|
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
|
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(
|
mock_celery.apply_async.assert_any_call(
|
||||||
kwargs={'process_day': process_date, 'notification_type': notification_type},
|
kwargs={'process_day': process_date, 'notification_type': notification_type},
|
||||||
queue=QueueNames.REPORTING
|
queue=QueueNames.REPORTING
|
||||||
|
|||||||
Reference in New Issue
Block a user