mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Reduce the number of days to recalculate billing. It's not necessary to calculate longer than 4 days.
This commit is contained in:
@@ -24,7 +24,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, 10):
|
for i in range(0, 4):
|
||||||
process_day = day_start - timedelta(days=i)
|
process_day = day_start - timedelta(days=i)
|
||||||
|
|
||||||
transit_data = fetch_billing_data_for_day(process_day=process_day)
|
transit_data = fetch_billing_data_for_day(process_day=process_day)
|
||||||
|
|||||||
@@ -286,14 +286,13 @@ def test_create_nightly_billing_null_sent_by_sms(
|
|||||||
|
|
||||||
@freeze_time('2018-01-15T03:30:00')
|
@freeze_time('2018-01-15T03:30:00')
|
||||||
def test_create_nightly_billing_consolidate_from_3_days_delta(
|
def test_create_nightly_billing_consolidate_from_3_days_delta(
|
||||||
sample_service,
|
|
||||||
sample_template,
|
sample_template,
|
||||||
mocker):
|
mocker):
|
||||||
|
|
||||||
mocker.patch('app.dao.fact_billing_dao.get_rate', side_effect=mocker_get_rate)
|
mocker.patch('app.dao.fact_billing_dao.get_rate', side_effect=mocker_get_rate)
|
||||||
|
|
||||||
# create records from 11th to 15th
|
# create records from 11th to 15th
|
||||||
for i in range(0, 11):
|
for i in range(0, 5):
|
||||||
create_notification(
|
create_notification(
|
||||||
created_at=datetime.now() - timedelta(days=i),
|
created_at=datetime.now() - timedelta(days=i),
|
||||||
template=sample_template,
|
template=sample_template,
|
||||||
@@ -305,7 +304,7 @@ def test_create_nightly_billing_consolidate_from_3_days_delta(
|
|||||||
)
|
)
|
||||||
|
|
||||||
notification = Notification.query.order_by(Notification.created_at).all()
|
notification = Notification.query.order_by(Notification.created_at).all()
|
||||||
assert datetime.date(notification[0].created_at) == date(2018, 1, 5)
|
assert datetime.date(notification[0].created_at) == date(2018, 1, 11)
|
||||||
|
|
||||||
records = FactBilling.query.all()
|
records = FactBilling.query.all()
|
||||||
assert len(records) == 0
|
assert len(records) == 0
|
||||||
@@ -313,8 +312,8 @@ def test_create_nightly_billing_consolidate_from_3_days_delta(
|
|||||||
create_nightly_billing()
|
create_nightly_billing()
|
||||||
records = FactBilling.query.order_by(FactBilling.bst_date).all()
|
records = FactBilling.query.order_by(FactBilling.bst_date).all()
|
||||||
|
|
||||||
assert len(records) == 10
|
assert len(records) == 4
|
||||||
assert records[0].bst_date == date(2018, 1, 5)
|
assert records[0].bst_date == date(2018, 1, 11)
|
||||||
assert records[-1].bst_date == date(2018, 1, 14)
|
assert records[-1].bst_date == date(2018, 1, 14)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user