test(tradein/scraper-kit): prove cian_valuation kit path safe for #2337 (#2335) #2342

Merged
lekss361 merged 1 commit from feat/tradein-migrate-cian-valuation-kit into main 2026-07-03 22:59:46 +00:00
Owner

Closes #2335 (Group E2 эпика #2277 — sub-issue #2308, core valuation).

Контекст

Kit-сторона (scraper_kit.providers.cian.valuation) уже была полностью портирована ранее —
задача этого issue: верификация + доказательства безопасности, не порт. Production-код не
тронут вообще
— только новый тест-файл.

Callers

Только estimator.py:3121 (не тронут, это #2337) и app/tasks/cian_history_backfill.py:284
(уже осознанно оставлен на legacy в Group C/#2310, не новый пробел).

⚠️ Важная находка для #2337 — observability gap

estimator.py's except-блок (~3143): logger.warning("cian_valuation: lookup failed (graceful): %s", exc) — без exc_info=True, WARNING-уровень. Проверено: GlitchTip
(LoggingIntegration(event_level=logging.ERROR) в app/main.py + scheduler_main.py) НЕ
ловит WARNING — событие не создастся. Ошибка конфигурации (config= typo при переключении в
#2337) была бы невидима в мониторинге, неотличима от штатной "источник недоступен".
Рекомендация для #2337: logger.exception или отдельная severity/сообщение для этого
конкретного класса ошибок.

Тесты

  • test_estimate_via_cian_valuation_full_pipeline_parity — полный async pipeline через
    tests/support/parity.assert_parity, мокается только сетевая граница
    (curl_cffi.AsyncSession), остальное (extract_state, auth-check, parse, sanity-check) —
    реальный код
  • test_kit_estimate_via_cian_valuation_requires_config — доказывает TypeError без config
  • test_kit_cian_session_config_requirement_asymmetry — документирует асимметрию
    (load_session требует config обязательно, mark_session_invalid — нет)

Проверено

  • Новый файл: 12/12 passed
  • Полный backend suite: 3220 passed / 6 skipped / 1 pre-existing unrelated failure
  • ruff check — чисто
  • Code-review: APPROVE (все claims независимо перепроверены, включая observability-находку
    через прямое чтение Sentry/GlitchTip конфига)
Closes #2335 (Group E2 эпика #2277 — sub-issue #2308, core valuation). ## Контекст Kit-сторона (`scraper_kit.providers.cian.valuation`) уже была полностью портирована ранее — задача этого issue: верификация + доказательства безопасности, не порт. **Production-код не тронут вообще** — только новый тест-файл. ## Callers Только `estimator.py:3121` (не тронут, это #2337) и `app/tasks/cian_history_backfill.py:284` (уже осознанно оставлен на legacy в Group C/#2310, не новый пробел). ## ⚠️ Важная находка для #2337 — observability gap `estimator.py`'s except-блок (~3143): `logger.warning("cian_valuation: lookup failed (graceful): %s", exc)` — без `exc_info=True`, WARNING-уровень. Проверено: GlitchTip (`LoggingIntegration(event_level=logging.ERROR)` в `app/main.py` + `scheduler_main.py`) НЕ ловит WARNING — событие не создастся. Ошибка конфигурации (`config=` typo при переключении в #2337) была бы **невидима в мониторинге**, неотличима от штатной "источник недоступен". Рекомендация для #2337: `logger.exception` или отдельная severity/сообщение для этого конкретного класса ошибок. ## Тесты - `test_estimate_via_cian_valuation_full_pipeline_parity` — полный async pipeline через `tests/support/parity.assert_parity`, мокается только сетевая граница (`curl_cffi.AsyncSession`), остальное (extract_state, auth-check, parse, sanity-check) — реальный код - `test_kit_estimate_via_cian_valuation_requires_config` — доказывает `TypeError` без config - `test_kit_cian_session_config_requirement_asymmetry` — документирует асимметрию (`load_session` требует config обязательно, `mark_session_invalid` — нет) ## Проверено - Новый файл: 12/12 passed - Полный backend suite: 3220 passed / 6 skipped / 1 pre-existing unrelated failure - ruff check — чисто - Code-review: ✅ APPROVE (все claims независимо перепроверены, включая observability-находку через прямое чтение Sentry/GlitchTip конфига)
lekss361 added 1 commit 2026-07-03 22:54:36 +00:00
test(tradein/scraper-kit): prove cian_valuation kit path safe for #2337 (#2335)
All checks were successful
CI Trade-In / changes (pull_request) Successful in 6s
CI / changes (pull_request) Successful in 7s
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
CI Trade-In / backend-tests (pull_request) Successful in 1m35s
53287da886
scraper_kit.providers.cian.valuation.estimate_via_cian_valuation (and
session.load_session) already existed with mandatory config: ScraperConfig
(no default) — this was ground prepared ahead of Group E2, not new work here.
This change proves it's safe to switch estimator.py's import to it (#2337):

- Extends the existing _parse_valuation_state golden-parity test with a
  full-pipeline parity test (cache-miss -> load_session -> curl_cffi fetch ->
  extract_state -> auth-check -> parse -> sanity-check), wired with
  config=RealScraperConfig() per the #2306 convention
  (app/services/cian_price_history.py).
- Adds a regression guard proving estimate_via_cian_valuation raises TypeError
  when config= is omitted, and documents why that must stay mandatory:
  estimator.py's call site (line ~3143) sits inside a blanket
  `except Exception` that only does `logger.warning(..., exc)` (no exc_info,
  no logger.exception) -- below GlitchTip's ERROR-level capture threshold
  (see LoggingIntegration(event_level=logging.ERROR) in app/main.py), so a
  TypeError from a missing config= would be logged but invisible in
  GlitchTip/Sentry, indistinguishable from ordinary graceful degradation.
- Documents an asymmetry vs. the task's initial assumption: kit's
  load_session requires config= mandatorily, but mark_session_invalid does
  NOT take a config parameter at all (confirmed by inspection, not a
  footgun -- just noting the actual contract).
- Confirms app/services/estimator.py is not the only real caller:
  app/tasks/cian_history_backfill.py also imports estimate_via_cian_valuation
  directly and deliberately stays on the legacy import for now (see its own
  comment referencing issue #2308) -- out of scope for this change, flagged
  for whoever picks up cian_history_backfill's migration.

Full backend test suite: 3211 passed, 6 skipped, 1 pre-existing unrelated
failure (test_search_api.py::test_search_cache_hit, 401 vs 200 auth issue,
reproduces identically on main without this change).
lekss361 merged commit 17cf7344b3 into main 2026-07-03 22:59:46 +00:00
lekss361 deleted branch feat/tradein-migrate-cian-valuation-kit 2026-07-03 22:59:47 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#2342
No description provided.