test(ingest): repair gated-post tests (#874 CI bounce)
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 18s
CI / backend-lint-and-test (push) Successful in 27s
CI / integration (push) Successful in 3m18s

The prior commit's Edit orphaned the recapture test's relink/stdout
assertions into the new preview test (F821 res_recap/downloader2/m1) and
the gated-skip test's written_paths check matched 'gated' in the tmp dir
name. Restore the recapture assertions to their function and assert on
the media basename instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 14:48:51 -04:00
parent b3afc2437e
commit 9422eadabe
+15 -14
View File
@@ -665,6 +665,19 @@ async def test_backfill_skips_already_captured_post_but_recapture_forces_it(
)
assert len(res_recap.post_record_paths) == 1 # gate bypassed → recaptured
assert downloader2.post_records == 1
assert res_recap.files_downloaded == 0 # no media re-download
assert downloader2.download_calls == 0
# The on-disk media is surfaced as a (path, CDN url) relink pair.
assert len(res_recap.relink_source_paths) == 1
rel_path, rel_url = res_recap.relink_source_paths[0]
assert rel_url == m1.url
# Diagnostic summary surfaces the post-record + relink counts (operator reads
# this off the event stdout to see what a recapture actually did).
assert "1 post-record(s), 1 relinked" in res_recap.stdout
# #842: per-post handling is written into the SAME run stdout (reuses the
# existing "Raw stdout" panel) — post_type + body length, so an empty body is
# self-explanatory by its post_type.
assert f"post p1 [image_file] body: {len('<p>body p1</p>')} chars" in res_recap.stdout
@pytest.mark.asyncio
@@ -689,7 +702,8 @@ async def test_gated_post_skipped_entirely_no_media_no_record(
# Only the accessible post's media downloaded; the gated post contributed
# nothing — no file, no post-record.
assert result.files_downloaded == 1
assert [p for p in result.written_paths if "gated" in p] == []
# (substring check on the basename only — the tmp dir name contains "gated")
assert not any(p.endswith("gated_1.jpg") for p in result.written_paths)
assert downloader.download_calls == 1
assert len(result.post_record_paths) == 1 # only the open post
assert downloader.post_records == 1
@@ -711,19 +725,6 @@ async def test_preview_excludes_gated_posts(source_id, sync_engine, tmp_path):
preview = ing.preview(source_id, "c1")
assert preview["total_new"] == 1 # only the open post
assert [s for s in preview["sample"] if s["title"] == "gated"] == []
assert res_recap.files_downloaded == 0 # no media re-download
assert downloader2.download_calls == 0
# The on-disk media is surfaced as a (path, CDN url) relink pair.
assert len(res_recap.relink_source_paths) == 1
rel_path, rel_url = res_recap.relink_source_paths[0]
assert rel_url == m1.url
# Diagnostic summary surfaces the post-record + relink counts (operator reads
# this off the event stdout to see what a recapture actually did).
assert "1 post-record(s), 1 relinked" in res_recap.stdout
# #842: per-post handling is written into the SAME run stdout (reuses the
# existing "Raw stdout" panel) — post_type + body length, so an empty body is
# self-explanatory by its post_type.
assert f"post p1 [image_file] body: {len('<p>body p1</p>')} chars" in res_recap.stdout
@pytest.mark.asyncio