19 lines
756 B
Python
19 lines
756 B
Python
from datetime import date
|
|
|
|
from app.nqi.adhoc import time_window
|
|
|
|
|
|
def test_relative_windows_from_a_monday():
|
|
today = date(2026, 11, 9)
|
|
assert _span("prev_month", 1, today) == ("2026-10-01", "2026-10-31")
|
|
assert _span("prev_week", 1, today) == ("2026-11-02", "2026-11-08")
|
|
assert _span("prev_day", 1, today) == ("2026-11-08", "2026-11-08")
|
|
assert _span("prev_days", 3, today) == ("2026-11-06", "2026-11-08")
|
|
assert _span("prev_weeks", 2, today) == ("2026-10-26", "2026-11-08")
|
|
assert _span("prev_months", 2, today) == ("2026-09-01", "2026-10-31")
|
|
|
|
|
|
def _span(mode: str, count: int, today: date) -> tuple[str, str]:
|
|
start, end = time_window(mode, count, today)
|
|
return start.strftime("%Y-%m-%d"), end.strftime("%Y-%m-%d")
|