mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
Merge pull request #3543 from alphagov/run-billing-for-longer-178125825
Recalculate billing rows for 10 days (prev. 4)
This commit is contained in:
@@ -25,7 +25,7 @@ def create_nightly_billing(day_start=None):
|
|||||||
else:
|
else:
|
||||||
# When calling the task its a string in the format of "YYYY-MM-DD"
|
# When calling the task its a string in the format of "YYYY-MM-DD"
|
||||||
day_start = datetime.strptime(day_start, "%Y-%m-%d").date()
|
day_start = datetime.strptime(day_start, "%Y-%m-%d").date()
|
||||||
for i in range(0, 4):
|
for i in range(0, 10):
|
||||||
process_day = (day_start - timedelta(days=i)).isoformat()
|
process_day = (day_start - timedelta(days=i)).isoformat()
|
||||||
|
|
||||||
create_nightly_billing_for_day.apply_async(
|
create_nightly_billing_for_day.apply_async(
|
||||||
|
|||||||
@@ -49,15 +49,15 @@ def mocker_get_rate(
|
|||||||
|
|
||||||
@freeze_time('2019-08-01')
|
@freeze_time('2019-08-01')
|
||||||
@pytest.mark.parametrize('day_start, expected_kwargs', [
|
@pytest.mark.parametrize('day_start, expected_kwargs', [
|
||||||
(None, ['2019-07-31', '2019-07-30', '2019-07-29', '2019-07-28']),
|
(None, [f'2019-07-{31-i}' for i in range(10)]),
|
||||||
('2019-07-21', ['2019-07-21', '2019-07-20', '2019-07-19', '2019-07-18']),
|
('2019-07-21', [f'2019-07-{21-i}' for i in range(10)]),
|
||||||
])
|
])
|
||||||
def test_create_nightly_billing_triggers_tasks_for_days(notify_api, mocker, day_start, expected_kwargs):
|
def test_create_nightly_billing_triggers_tasks_for_days(notify_api, mocker, day_start, expected_kwargs):
|
||||||
mock_celery = mocker.patch('app.celery.reporting_tasks.create_nightly_billing_for_day')
|
mock_celery = mocker.patch('app.celery.reporting_tasks.create_nightly_billing_for_day')
|
||||||
create_nightly_billing(day_start)
|
create_nightly_billing(day_start)
|
||||||
|
|
||||||
assert mock_celery.apply_async.call_count == 4
|
assert mock_celery.apply_async.call_count == 10
|
||||||
for i in range(4):
|
for i in range(10):
|
||||||
assert mock_celery.apply_async.call_args_list[i][1]['kwargs'] == {'process_day': expected_kwargs[i]}
|
assert mock_celery.apply_async.call_args_list[i][1]['kwargs'] == {'process_day': expected_kwargs[i]}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user