From 50e2360d14450d9df7c2f875a30ea84e9d7dc335 Mon Sep 17 00:00:00 2001 From: Matthew Daubney Date: Mon, 28 Sep 2026 11:27:45 +0100 Subject: [PATCH] Fix a Monday-morning-flaky weekly preview test test_preview_weekly_reflects_the_week_in_progress hardcoded its scrobble at noon UTC on "this week's Monday", but the preview window is [week start, now) - so it failed for real whenever CI ran before noon UTC on a Monday (as it just did in run 624). Use now - 1 minute instead, which is always inside the window regardless of what time the test runs. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW --- tests/test_federation_api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_federation_api.py b/tests/test_federation_api.py index fe7d981..ba10649 100644 --- a/tests/test_federation_api.py +++ b/tests/test_federation_api.py @@ -190,14 +190,16 @@ def test_public_post_404s_for_followers_only_deleted_or_unknown(fed_client, fed_ def test_preview_weekly_reflects_the_week_in_progress(fed_client, fed_auth, fed_ctx, user): + # The preview window is [this week's Monday 00:00, now) - a play has to be in the + # past relative to the moment the test runs, not just dated "this Monday", or this + # flakes whenever CI happens to run before noon UTC on a Monday. now = datetime.now(UTC) - monday = now.date() - timedelta(days=now.weekday()) db.session.add( Scrobble( user_id=user.id, artist="Radiohead", track="Reckoner", - played_at=datetime(monday.year, monday.month, monday.day, 12, tzinfo=UTC), + played_at=now - timedelta(minutes=1), ) ) db.session.commit()