gendesign/tradein-mvp/backend/tests
lekss361 7af97c2c59 feat(tradein): integrate Avito IMV as 5th evaluation source (on-demand cached)
Stage 3 of AvitoScraper_v2.

- _get_or_fetch_imv_cached(db, **params) — TTL 24h по cache_key (sha256 of address+params)
  * Cache HIT: SELECT avito_imv_evaluations WHERE cache_key AND fetched_at > NOW() - 24h
  * Cache MISS: evaluate_via_imv + save_imv_evaluation (2 HTTP requests to Avito)
  * Graceful: на любой error → return None, estimator продолжает без IMV
- В estimate_quality после aggregation:
  * Map house_type/repair_state → Avito IMV формат (_IMV_HOUSE_TYPE_MAP, _IMV_REPAIR_MAP)
  * Skip IMV если payload без required fields (rooms/area/floor/total_floors/house_type/repair)
  * Append 'avito_imv' в sources_used (saved + returned)
- После INSERT estimate: link estimate_id в avito_imv_evaluations row (для analytics joining)
- Logging: imv=<price> в final estimate log line
- pytest offline (4 tests): house_type_map / repair_map / cache_miss_fetch / fetch_failure_graceful
  * anyio.run() вместо pytest-asyncio (не установлен в tradein-mvp venv)
  * DATABASE_URL dummy через os.environ.setdefault (Settings fail-fast без него)

IMV — ON-DEMAND only (per estimator call), НЕ в cron-scrape.
Refs: AvitoScraper_v2_Implementation_Plan Stage 3.
2026-05-23 15:48:50 +03:00
..
__init__.py feat(tradein): avito_imv.py — Avito IMV evaluation API client (2 requests) (#444) 2026-05-23 12:16:47 +00:00
test_avito_detail_parse.py feat(tradein): avito_detail.py — detail page parser (30+ fields incl. domoteka) (#443) 2026-05-23 12:17:15 +00:00
test_avito_houses_parse.py feat(tradein): avito_houses.py — Houses Catalog parser (state + reviews + history + recs) (#449) 2026-05-23 12:37:24 +00:00
test_avito_imv_parse.py feat(tradein): avito_imv.py — Avito IMV evaluation API client (2 requests) (#444) 2026-05-23 12:16:47 +00:00
test_cian_state_parser.py feat(tradein): cian_state_parser shared utility + ScrapedLot Cian fields (#447) 2026-05-23 12:35:01 +00:00
test_estimator_imv_integration.py feat(tradein): integrate Avito IMV as 5th evaluation source (on-demand cached) 2026-05-23 15:48:50 +03:00