gendesign/tradein-mvp/backend/tests
lekss361 5bf650c843 fix(tradein): route sweep shared-session (SERP+detail) через mobile proxy (#623)
Корень банов city-sweep: pipeline создаёт собственную shared AsyncSession и
присваивает её scraper._cffi, ПЕРЕЗАТИРАЯ проксированную сессию из
AvitoScraper.__aenter__ (#788). Через эту же сессию идёт и SERP, и detail-энричмент
(fetch_detail), и houses. Сессия создавалась без proxies → detail-страницы летели
с datacenter-IP → HTTP 429 → весь run mark_banned (scrape_runs id=9: «Avito detail
HTTP 429 …»). Единичный /admin/scrape работал, т.к. зовёт fetch_around напрямую
(проксированный _cffi из __aenter__), а не pipeline.

- scrape_pipeline.py: helper _avito_proxies() (из settings.avito_proxy_url) →
  proxies= в обе shared AsyncSession (run_avito_pipeline + run_avito_city_sweep).
  Пусто/нет env → прямое подключение (dev no-op). n1/yandex не трогаем (им прокси
  не нужен, не жжём мобильный трафик).
- test: _avito_proxies None без env / {http,https} при заданном URL.

Проверено: 18 passed (anti-bot + serp_date). ruff clean. Требует deploy (cron
city-sweep каждые 2ч на проде продолжит банить detail-429 до выката).

Refs #623, #788, #562.
2026-05-30 21:02:26 +03:00
..
fixtures fix(scrapers): avito listing_date from sortTimeStamp JSON (#726) (#729) 2026-05-30 14:13:38 +00:00
matching chore(tradein): close pre-commit ruff gap + add CI pytest gate (#666) (#675) 2026-05-29 19:18:48 +00:00
scrapers fix(tradein): route sweep shared-session (SERP+detail) через mobile proxy (#623) 2026-05-30 21:02:26 +03:00
scripts feat(tradein): приоритизировать DaData house-backfill на дома с листингами (accuracy #2) 2026-05-28 15:17:01 +05:00
services feat(tradein): expected-sold price in estimate PDF (#648 S5b — final) (#665) 2026-05-29 14:09:46 +00:00
tasks fix(tradein): geocode backfill + remove Avito exclusion from estimator (#490) 2026-05-23 20:03:48 +00: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_account_quota.py fix(tradein): atomic conditional quota increment — close TOCTOU (#747) (#749) 2026-05-30 15:52:34 +00:00
test_admin_ssrf.py fix(tradein): SSRF host-allowlist на admin scrape + удалён dead ADMIN_TOKEN (Refs #756) (#778) 2026-05-30 16:27:19 +00:00
test_api_avito_stage4a.py test(tradein): fix /houses test broken by IDOR guard — unblock deploy (#690) (#709) 2026-05-30 09:34:31 +00:00
test_asking_to_sold_ratio.py fix(ratio): ppm² потолок asking→sold в конфиг, default 1.2M (Refs #767) (#790) 2026-05-30 16:57:09 +00:00
test_audit_address_mismatch.py feat(tradein): Phase 1 of #582 — address mismatch audit infrastructure 2026-05-25 12:50:30 +05:00
test_avito_address_clean.py fix(tradein-avito): strip Emotion CSS from listings.address (#502) 2026-05-24 10:52:50 +00:00
test_avito_detail_parse.py feat(tradein): infer repair_state from listing description text (#622) (#632) 2026-05-28 15:37:34 +00:00
test_avito_houses_parse.py fix(tradein): decode Avito houses URL-encoded __preloadedState__ (#566) 2026-05-28 15:58:19 +05:00
test_avito_imv_parse.py fix(tradein-imv): harden Avito IMV anti-bot path + offline contract tests (#565) 2026-05-28 16:29:05 +05:00
test_avito_relative_date.py fix(tradein): Avito listing_date extraction (3 формата) (#601) 2026-05-27 12:55:27 +00:00
test_avito_serp_date.py feat(tradein): Avito mobile proxy egress + firewall detect + MSK date (#623, #726) (#788) 2026-05-30 16:52:35 +00:00
test_backfill_house_coords.py feat(tradein): Phase 2-3 of #582 — Yandex backfill + canonical audit (#591) 2026-05-27 06:30:54 +00:00
test_backtest_estimator.py feat(backtest): per-rooms asking→sold correction block (#648 S1) (#650) 2026-05-29 13:11:55 +00:00
test_base_save_listings.py fix(scrapers): stable dedup_hash — drop price_rub + strip URL query (Refs #753) (#761) 2026-05-30 16:10:27 +00:00
test_cian_detail.py feat(tradein): infer repair_state from listing description text (#622) (#632) 2026-05-28 15:37:34 +00:00
test_cian_newbuilding.py feat(tradein): cian_newbuilding.py — ЖК catalog scraper (chart + reliability + offers, Wave 4 Worker C) (#459) 2026-05-23 13:23:11 +00:00
test_cian_serp_scraper.py feat(tradein): cian.py SERP refactor — state-based extraction (137 fields, no jitter) (#450) 2026-05-23 12:52:04 +00:00
test_cian_session.py fix(cian): verify_session на curl_cffi impersonate — ban != cookies expired (Refs #768) (#785) 2026-05-30 16:40:54 +00:00
test_cian_state_parser.py fix(tradein): word-boundary street match + cian unescape robustness (Refs #769 A1+D) (#798) 2026-05-30 17:18:33 +00:00
test_cian_valuation.py feat(tradein): cian_valuation.py — auth-required Calculator scraper + 24h cache (#465) 2026-05-23 13:43:34 +00:00
test_city_sweep.py feat(tradein): city sweep — auto ЕКБ pipeline (#477) 2026-05-23 14:38:07 +00:00
test_deals_sanitize.py fix(tradein): sanitize ДКП deal outliers (floor / ppm²) (#699) (#733) 2026-05-30 14:31:44 +00:00
test_estimate_idor.py fix(tradein): rehydrate POST-only fields on GET /estimate/{id} (#696) (#710) 2026-05-30 11:05:52 +00:00
test_estimator_cian_integration.py feat(tradein): estimator additive expected_sold price (#648 S3) (#661) 2026-05-29 13:37:33 +00:00
test_estimator_cohort.py fix(tradein-estimator): extend cohort filter to Tier S + Tier H, fix late_soviet overlap (#522) 2026-05-24 13:14:59 +00:00
test_estimator_enrich.py feat(tradein): enrich /estimate response for web map, distribution, exposure & trend (#685) 2026-05-30 07:32:40 +00:00
test_estimator_expected_sold.py fix(estimator): expected_sold guard listings_clean → median_price>0 (Refs #773) (#784) 2026-05-30 16:39:08 +00:00
test_estimator_floor_optional.py feat(tradein): этаж/этажность optional + best test presets по deal count (#558) 2026-05-24 21:44:44 +00:00
test_estimator_imv_blend.py feat(tradein): blend Avito IMV anchor into estimate + ДКП corridor advisory (#651, #652) (#674) 2026-05-29 17:42:06 +00:00
test_estimator_imv_integration.py feat(tradein): integrate Avito IMV as 5th evaluation source (on-demand cached) (#452) 2026-05-23 13:08:22 +00:00
test_estimator_null_floor_timeout.py fix(tradein): time-budget estimate enrichment + observable errors to stop opaque 502 (#654) (#673) 2026-05-29 17:22:02 +00:00
test_estimator_pure_units.py test(tradein): estimator pure-helper unit tests + fix None crash in _filter_outliers (#580) (#640) 2026-05-29 08:24:18 +00:00
test_estimator_repair_coef.py feat(tradein): estimator additive expected_sold price (#648 S3) (#661) 2026-05-29 13:37:33 +00:00
test_estimator_source_quota.py feat(tradein): estimator additive expected_sold price (#648 S3) (#661) 2026-05-29 13:37:33 +00:00
test_estimator_yandex_integration.py feat(yandex-valuation): link history rows to houses via match_or_create_house (#531) 2026-05-24 14:28:30 +00:00
test_extract_short_addr.py feat(tradein-estimator): tiered house-match S→H→W (#507) 2026-05-24 12:41:12 +00:00
test_geocode_reverse_api.py feat(tradein): MapPicker snap marker — Phase 5 of #582 (#594) 2026-05-27 09:30:17 +00:00
test_history_scope.py chore(tradein): close pre-commit ruff gap + add CI pytest gate (#666) (#675) 2026-05-29 19:18:48 +00:00
test_insufficient_data_flag.py feat(tradein): insufficient_data flag on AggregatedEstimate (#697) (#734) 2026-05-30 14:40:04 +00:00
test_listing_source_snapshot.py feat(tradein): per-source listing price history — schema + daily snapshot (#570) (#646) 2026-05-29 12:18:04 +00:00
test_matching.py fix(tradein-matching): pg_advisory_xact_lock to prevent duplicate house INSERTs (#501) 2026-05-24 10:52:10 +00:00
test_me_brand.py feat(tradein): brand-by-account + result IA redesign (distinct asking/sale prices) (#683) 2026-05-30 06:45:14 +00:00
test_n1_city_sweep.py feat(scrapers): wire N1.ru city sweep — pipeline + scheduler + admin endpoint (#575) (#745) 2026-05-30 15:43:38 +00:00
test_n1_floor_parse.py feat(scrapers/n1): извлекать floor/total_floors из ведущего N/M-токена (Refs #795) (#802) 2026-05-30 17:31:13 +00:00
test_pdf_security.py fix(pdf): brand-spoof + median=0 empty-state + SSRF + дисклеймер + sources (Refs #772) (#789) 2026-05-30 16:55:56 +00:00
test_ratelimit.py fix(tradein): bypass rate-limit for authenticated pilots + configurable limit (#655) (#669) 2026-05-29 15:56:30 +00:00
test_rbac.py feat(rbac): pilot scope → только /trade-in/** (#587) 2026-05-26 07:40:44 +00:00
test_repair_state_normalizer.py feat(tradein): infer repair_state from listing description text (#622) (#632) 2026-05-28 15:37:34 +00:00
test_rosreestr_dedup_key.py fix(tradein): plain natural-key dedup_hash for rosreestr deals (#576) (#638) 2026-05-29 06:56:35 +00:00
test_sales_vs_listings.py feat(tradein): sales-vs-listings endpoint (PR K, foundation #564) (#597) 2026-05-27 11:55:44 +00:00
test_same_building_anchor.py fix(tradein): sync n_analogs to anchor count when anchor drives headline (#695) (#739) 2026-05-30 15:25:35 +00:00
test_same_building_match.py feat(tradein): same-building матчинг аналогов по house_id (#6) 2026-05-28 13:55:51 +05:00
test_scheduler.py fix(scheduler): atomic _claim_run via advisory xact lock (Refs #750) (#752) 2026-05-30 16:04:33 +00:00
test_scrape_pipeline.py feat(tradein): scrape_pipeline.py — Avito full orchestrator (search → houses → detail) (#451) 2026-05-23 12:55:13 +00:00
test_scraper_settings.py feat(tradein): global scraper delay setting (applies across all scrapers) (#485) 2026-05-23 15:43:28 +00:00
test_search_api.py feat(tradein): Phase 3.2 — /api/v1/search endpoint + Redis cache (#479) 2026-05-23 14:44:22 +00:00
test_sentry_scrub.py feat(tradein): enrich GlitchTip SDK init — integrations + PII scrub (#396) (#643) 2026-05-29 09:23:17 +00:00
test_snapshot_writer.py fix(tradein): implement listings_snapshots + offer_price_history writers (#567) (#624) 2026-05-28 13:49:52 +00:00
test_street_deals_endpoint.py fix(tradein): word-boundary street match + cian unescape robustness (Refs #769 A1+D) (#798) 2026-05-30 17:18:33 +00:00
test_yandex_city_sweep.py feat(scheduler): dormant Yandex Realty city-sweep (#561) (#642) 2026-05-29 08:50:10 +00:00
test_yandex_detail.py feat(tradein): yandex_detail.py — Product JSON-LD + DOM detail parser (#466) 2026-05-23 13:45:09 +00:00
test_yandex_helpers.py fix(tradein): Yandex listing_date — keyword + absolute-no-year (#602) 2026-05-27 13:11:22 +00:00
test_yandex_newbuilding.py feat(tradein): yandex_newbuilding.py — ЖК landing parser (149 selectors + NLP) (#467) 2026-05-23 13:46:45 +00:00
test_yandex_realty_serp.py fix(scrapers): yandex area из embedded-state JSON (Refs #775) (#783) 2026-05-30 16:38:12 +00:00
test_yandex_scrapers_delay_wiring.py feat(tradein): scraper_settings live-config + Yandex admin trigger endpoints (#484) 2026-05-23 15:28:34 +00:00
test_yandex_valuation.py fix(yandex-valuation): off-by-one cell index in _parse_row_cells (#552) 2026-05-24 19:57:17 +00:00
test_yandex_valuation_save.py feat(yandex-valuation): link history rows to houses via match_or_create_house (#531) 2026-05-24 14:28:30 +00:00