test(patreon): adjust deterministic clock for the new per-media should_stop read
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user