From 14c4dd1ea0b613bcb7d779c403345dcc4c0c302a Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sat, 6 Jun 2026 22:26:27 -0400 Subject: [PATCH] test(patreon): adjust deterministic clock for the new per-media should_stop read MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mid-post time-box check (619e771) reads time.monotonic() once more per post, so test_backfill_budget_cut_returns_partial_with_progress's discrete tick sequence shifted — the >budget tick (200) landed on post1's first-item check instead of post2's gate, cutting post1 to 0 files. Add the extra tick (20, still under budget) so post1's item downloads, matching production where the gate and the first should_stop are microseconds apart. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/test_patreon_ingester.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_patreon_ingester.py b/tests/test_patreon_ingester.py index bfe20a0..b96fa00 100644 --- a/tests/test_patreon_ingester.py +++ b/tests/test_patreon_ingester.py @@ -349,11 +349,14 @@ async def test_tick_does_not_checkpoint_cursor(source_id, sync_engine, tmp_path, async def test_backfill_budget_cut_returns_partial_with_progress( source_id, sync_engine, tmp_path, monkeypatch, ): - # Deterministic clock: start=0, post1 check=10 (ok), post2 check=200 (>budget). - # run() lives in ingest_core now, so patch the clock there (the same global - # time module object, but we reference it through the module that uses it). + # Deterministic clock: start=0; post1 gate=10 (ok); post1's per-media + # should_stop=20 (still ok, so post1's item downloads); post1 live-progress + # read=200; post2 gate=250 (>budget → cut). The per-media should_stop check + # (added 2026-06-07 to bound media-dense posts) reads the clock once more per + # post, so the sequence carries the extra tick. run() lives in ingest_core + # now, so patch the clock there. import backend.app.services.ingest_core as core - ticks = iter([0.0, 10.0, 200.0, 250.0]) + ticks = iter([0.0, 10.0, 20.0, 200.0, 250.0]) last = [0.0] def fake_monotonic():