Skip to main content
tests/test_expand_events.py · chapter Tests and team tooling, file 4 · 104 lines · open in the repository

What it does

The date-rule expander (common.contracts.expand_events) turns event_types.csv rules and event_dates.csv listed dates into actual per-year occurrences.

What is inside

  • _by_type_and_year(rows, event_type, year) · line 12

What it checks

  • output matches the events contract columns (line 16)
  • black friday and cyber monday 2024 are correct (line 22)
  • fixed rule repeats every year (line 30)
  • listed events come from event dates csv and are year filtered (line 36)
  • nth weekday rolls to the 5th occurrence when it exists (line 51)
  • nth weekday raises instead of silently rolling into the next month (line 56)
  • offset anchor outside event types csv raises a clear error (line 62)
  • offset event near year boundary lands in the right year (line 68)
  • one day events have equal start and end (line 78)
  • every row is market wide by default (line 85)
  • expand events finds offset occurrences anchored in the prior year (line 90)

Connections

Uses: src/common/contracts.py

Source

tests/test_expand_events.py