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 <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 1ad3427669
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()