Skip to content

Fix: Pin the date in schedule tests so they pass on both sides of DST - #780

Merged
hunter-read merged 1 commit into
mainfrom
fix/dst-test-failures
Nov 2, 2026
Merged

hunter-read merged 1 commit into
mainfrom
fix/dst-test-failures

Conversation

@hunter-read

Copy link
Copy Markdown
Owner

Summary

Five tests in backend/tests/test_campaign_schedule.py started failing on 2026-11-01, when DST ended. Each one failed with '18:30' == '19:30'.

A legacy UTC schedule clock carries no offset, so the write path (_utc_clock_to_local) and the startup migration (_migrate_schedule_times_to_local) both resolve it against today's offset. That's by design: 02:30Z is 19:30 under PDT but 18:30 under PST. The tests hard-coded the summer answer, so they only passed for half the year.

Changes

  • New _pin_today helper patches datetime.date.today() only in backend.models.db and backend.routers.campaigns.schedule, never globally.
  • The three affected classes (TestLocalTimeModel, TestScheduleTimeMigration, TestStaleBundleRepair) are pinned to a July date with a summer_today fixture.
  • New TestLegacyClockFollowsTodaysOffset pins a January date and asserts 18:30, covering the PST half on both the write path and the migration.

No application code changes.

Testing

  • Full backend suite on main before the fix: 5 failed, 8548 passed. These were the only failures.
  • Schedule, schedule-helper and calendar tests after the fix: 119 passed, both serially and with -n 4 --dist loadgroup.
  • ruff check backend/ and mypy backend/ are clean. The frontend suite was already green (7053 passed).

🤖 Generated with Claude Code

A legacy UTC schedule clock carries no offset, so the write path and the
startup migration resolve it against today's: 02:30Z is 19:30 under PDT
but 18:30 under PST. Five tests hard-coded the summer answer and started
failing when DST ended on 2026-11-01.

The tests now pin "today" to a summer date in the two modules that do the
conversion, and two new winter-pinned tests cover the PST half of the year.
No application code changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hunter-read
hunter-read merged commit f03dcdb into main Nov 2, 2026
13 checks passed
@hunter-read
hunter-read deleted the fix/dst-test-failures branch November 2, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant