This commit is contained in:
2025-08-01 19:33:54 -03:00
parent f5bd1e80d6
commit 5c57da7ecb
4 changed files with 80 additions and 42 deletions

View File

@@ -24,13 +24,13 @@ def test_append_enrollment(
assert app.lambda_handler(event, lambda_context) # type: ignore
r = dynamodb_persistence_layer.collection.query(
KeyPair('BILLING#ORG#cJtK9SsnJhKPyxESe7g3DG', 'START#2025-06-06#END#2025-07-05')
KeyPair('BILLING#ORG#cJtK9SsnJhKPyxESe7g3DG', 'START#2025-05-06#END#2025-06-05')
)
items = r['items']
assert items[0]['sk'] == 'START#2025-06-06#END#2025-07-05#SCHEDULE#AUTO_CLOSE'
assert items[0]['sk'] == 'START#2025-05-06#END#2025-06-05#SCHEDULE#AUTO_CLOSE'
assert (
items[1]['sk']
== 'START#2025-06-06#END#2025-07-05#ENROLLMENT#945e8672-1d72-45c6-b76c-ac06aa8b52ab'
== 'START#2025-05-06#END#2025-06-05#ENROLLMENT#945e8672-1d72-45c6-b76c-ac06aa8b52ab'
)
assert items[2]['sk'] == 'START#2025-06-06#END#2025-07-05'
assert items[2]['sk'] == 'START#2025-05-06#END#2025-06-05'

View File

@@ -4,28 +4,61 @@ from utils import get_billing_period
def test_get_billing_period():
assert get_billing_period(billing_day=29, year=2025, month=2) == (
date(2025, 2, 28),
date(2025, 3, 28),
)
assert get_billing_period(
billing_day=15,
date_=date(2023, 3, 20),
) == (date(2023, 3, 15), date(2023, 4, 14))
assert get_billing_period(billing_day=31, year=2025, month=2) == (
date(2025, 2, 28),
date(2025, 3, 30),
assert get_billing_period(
billing_day=15,
date_=date(2023, 3, 10),
) == (date(2023, 2, 15), date(2023, 3, 14))
# Leap year
assert get_billing_period(
billing_day=30,
date_=date(year=2028, month=2, day=1),
) == (
date(2028, 1, 30),
date(2028, 2, 28),
)
# Leap year
assert get_billing_period(billing_day=29, year=2028, month=2) == (
assert get_billing_period(
billing_day=29,
date_=date(year=2028, month=3, day=1),
) == (
date(2028, 2, 29),
date(2028, 3, 28),
)
assert get_billing_period(billing_day=28, year=2025, month=2) == (
assert get_billing_period(
billing_day=28,
date_=date(year=2025, month=2, day=28),
) == (
date(2025, 2, 28),
date(2025, 3, 27),
)
assert get_billing_period(billing_day=5, year=2025, month=12) == (
date(2025, 12, 5),
date(2026, 1, 4),
assert get_billing_period(
billing_day=5,
date_=date(year=2025, month=12, day=1),
) == (
date(2025, 11, 5),
date(2025, 12, 4),
)
assert get_billing_period(billing_day=25, date_=date(2025, 12, 14)) == (
date(2025, 11, 25),
date(2025, 12, 24),
)
assert get_billing_period(billing_day=25, date_=date(2025, 1, 14)) == (
date(2024, 12, 25),
date(2025, 1, 24),
)
assert get_billing_period(10, date(2024, 1, 5)) == (
date(2023, 12, 10),
date(2024, 1, 9),
)