feat(tradein/scraper-kit): migrate backfill/enrichment tasks to kit (#2310) #2333

Merged
lekss361 merged 2 commits from feat/tradein-migrate-backfill-tasks-kit into main 2026-07-03 22:28:11 +00:00
Showing only changes of commit 116cd10046 - Show all commits

View file

@ -109,6 +109,8 @@ async def test_backfill_empty_snapshot_marks_done() -> None:
@pytest.mark.asyncio
async def test_backfill_processes_snapshot_to_completion() -> None:
"""3 listings -> all fetched and enriched, mark_done called."""
from app.services.scraper_adapters import RealScraperConfig
snapshot = _make_snapshot(3)
db = _mock_db(snapshot)
runs = MagicMock()
@ -119,7 +121,7 @@ async def test_backfill_processes_snapshot_to_completion() -> None:
with (
patch(_SETTINGS, fake_settings),
patch(_SESSION, return_value=AsyncMock()),
patch(_SCRAPER),
patch(_SCRAPER) as mock_scraper_cls,
patch(_RUNS, runs),
patch(_FETCH, mock_fetch),
patch(_SAVE, mock_save),
@ -136,6 +138,14 @@ async def test_backfill_processes_snapshot_to_completion() -> None:
assert mock_fetch.call_count == 3
runs.mark_done.assert_called_once()
runs.mark_failed.assert_not_called()
# #2310 regression guard: kit fetch_detail silently drops the backconnect-
# on-403 retry (and kit AvitoScraper can't read avito_proxy_rotate_url at
# all) unless config=RealScraperConfig() is passed/injected at the call
# site — assert_called()/call_count alone wouldn't catch someone dropping
# that kwarg later (mirrors #2306's test_backfill_wave2.py:282-286 pattern).
_, fetch_call_kwargs = mock_fetch.call_args
assert isinstance(fetch_call_kwargs.get("config"), RealScraperConfig)
assert isinstance(mock_scraper_cls.call_args.args[0], RealScraperConfig)
@pytest.mark.asyncio