From 5921157f359aef046c095e2d1e426bf359bb4a6a Mon Sep 17 00:00:00 2001 From: Byron Gamatos Date: Mon, 13 Jul 2026 15:36:05 +0200 Subject: [PATCH] test(stats): prove seconds-only recency on a fresh row (#948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodeRabbit on #947: the prior lastPlayPosition POST already stamped last_played_at, so the assertion passed even if the seconds-only path left it unchanged — a guard that cannot fail. Assert on a fresh row. Co-authored-by: Claude Fable 5 --- tests/test_song_stats_api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_song_stats_api.py b/tests/test_song_stats_api.py index 28e0a33..c021c63 100644 --- a/tests/test_song_stats_api.py +++ b/tests/test_song_stats_api.py @@ -480,8 +480,11 @@ def test_seconds_only_post_accrues_without_touching_position(client): # overwrite Continue with the end-of-song offset). assert row["plays"] == 0 assert row["last_position"] == pytest.approx(42.0) - # But the song WAS played — recency ordering must see it. - assert row["last_played_at"] + # Recency must come from the seconds-only POST itself — prove it on a + # FRESH row (the position touch above already stamps last_played_at, + # which would make an assertion here vacuous). + r2 = client.post("/api/stats", json={"filename": "fresh.archive", "seconds": 30}) + assert r2.json()["stats"]["last_played_at"] # Still counts as playing today for the streak. assert r.json()["progress"]["current_streak"] == 1