Fix a Monday-morning-flaky weekly preview test
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 15s
CI / federation-interop (push) Successful in 1m36s
CI / test (push) Successful in 3m11s
CI / assets (push) Successful in 8s
CI / python-package (push) Successful in 13s
CI / images (push) Successful in 22s
CI / trigger-deploy (push) Successful in 2s
CI / notify (push) Successful in 5s

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Sonnet 5 committed 2026-09-28 11:27:45 +01:00
1 parent b307b11440
commit 50e2360d14
1 file changed
+4 -2
+4 -2
View File
@@ -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()