From 8ef0f002ba8eb2a303710d26a73d884e9e8e84fd Mon Sep 17 00:00:00 2001 From: rayhpeng Date: Mon, 3 Aug 2026 10:54:04 +0800 Subject: [PATCH] test(schedule): stop the once-task router case expiring `test_a_timezone_change_on_a_once_task_keeps_the_same_instant` pinned a literal `2026-08-01T09:00:00+00:00`. These routes run against the real clock -- unlike the domain suite, they inject no `now=` -- and a `once` schedule must be in the future, so the case passed until that date went by and then failed on every run with a 422. Builds the instant relative to now instead. The assertions only compare created against updated, so nothing depended on the literal value. Co-Authored-By: Claude Opus 5 --- backend/tests/test_schedule_router.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/tests/test_schedule_router.py b/backend/tests/test_schedule_router.py index d33658c39..ab2670c0a 100644 --- a/backend/tests/test_schedule_router.py +++ b/backend/tests/test_schedule_router.py @@ -101,6 +101,11 @@ def _create_body(**overrides): return router_module.CreateScheduledTaskRequest(**{**defaults, **overrides}) +def _future_iso(*, days: int) -> str: + """An offset-aware instant safely in the future, as the wire spells it.""" + return (datetime.now(UTC) + timedelta(days=days)).isoformat() + + def _update_body(**fields): return router_module.UpdateScheduledTaskRequest(**fields) @@ -349,7 +354,11 @@ class TestUpdate: created = await _create( service, schedule_type="once", - schedule_spec={"run_at": "2026-08-01T09:00:00+00:00"}, + # Relative to now, not a literal: these routes run against the real + # clock (no `now=` injection), and `once` schedules must be in the + # future -- a hardcoded instant turns the test into a time bomb + # that passes until the date quietly goes by. + schedule_spec={"run_at": _future_iso(days=30)}, timezone="UTC", ) updated = await _call(