Files
saladeaula.digital/order-events/tests/test_utils.py
2025-07-25 11:20:01 -03:00

32 lines
771 B
Python

from datetime import date
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=31, year=2025, month=2) == (
date(2025, 2, 28),
date(2025, 3, 30),
)
# Leap year
assert get_billing_period(billing_day=29, year=2028, month=2) == (
date(2028, 2, 29),
date(2028, 3, 28),
)
assert get_billing_period(billing_day=28, year=2025, month=2) == (
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),
)