test_service_api_utils.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from room_cal.service_api._utils import month_bounds, months_in_range
  2. # ── month_bounds ──────────────────────────────────────────────────────────────
  3. def test_month_bounds_june():
  4. assert month_bounds(6, 2025) == ('2025-06-01', '2025-06-30')
  5. def test_month_bounds_january():
  6. assert month_bounds(1, 2025) == ('2025-01-01', '2025-01-31')
  7. def test_month_bounds_december_wraps_year():
  8. assert month_bounds(12, 2025) == ('2025-12-01', '2025-12-31')
  9. def test_month_bounds_february_non_leap():
  10. assert month_bounds(2, 2025) == ('2025-02-01', '2025-02-28')
  11. def test_month_bounds_february_leap():
  12. assert month_bounds(2, 2024) == ('2024-02-01', '2024-02-29')
  13. # ── months_in_range ───────────────────────────────────────────────────────────
  14. def test_months_in_range_single_month():
  15. assert months_in_range('2025-06-01', '2025-06-30') == [(6, 2025)]
  16. def test_months_in_range_single_day():
  17. assert months_in_range('2025-06-15', '2025-06-15') == [(6, 2025)]
  18. def test_months_in_range_two_consecutive():
  19. assert months_in_range('2025-06-01', '2025-07-31') == [(6, 2025), (7, 2025)]
  20. def test_months_in_range_mid_month_boundaries():
  21. assert months_in_range('2025-06-15', '2025-08-05') == [(6, 2025), (7, 2025), (8, 2025)]
  22. def test_months_in_range_cross_year():
  23. assert months_in_range('2025-11-01', '2026-02-28') == [
  24. (11, 2025), (12, 2025), (1, 2026), (2, 2026),
  25. ]
  26. def test_months_in_range_full_year():
  27. result = months_in_range('2025-01-01', '2025-12-31')
  28. assert result == [(m, 2025) for m in range(1, 13)]