From 24369a6bf2fc1b0fca1d29e6a1b260f2f89b123a Mon Sep 17 00:00:00 2001 From: bot-backend Date: Wed, 26 Aug 2026 18:47:29 +0500 Subject: [PATCH] =?UTF-8?q?test(3051):=20tests/services/test=5Flocation=5F?= =?UTF-8?q?index.py=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=B5=D0=B4=D1=91?= =?UTF-8?q?=D0=BD=20=D0=BD=D0=B0=20=5Fcovered=5Fregion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI поймал то, что мой локальный прогон пропустил: сьют в ПОДДИРЕКТОРИИ tests/services/ звал удалённый _in_ekb_bbox. Граничные точки сохранены те же (продукт-ядро 66 байт-в-байт), проверка дополнена кодом региона. Co-Authored-By: Claude Opus 5 --- .../tests/services/test_location_index.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tradein-mvp/backend/tests/services/test_location_index.py b/tradein-mvp/backend/tests/services/test_location_index.py index 9fa62103..6a720c27 100644 --- a/tradein-mvp/backend/tests/services/test_location_index.py +++ b/tradein-mvp/backend/tests/services/test_location_index.py @@ -3,7 +3,8 @@ No live Postgres needed — DB is a minimal fake returning queued results (mirrors the convention in tests/tasks/test_cadastral_geo_match.py / the deleted test_location_coef.py). Covers: - - pure functions: _category_weight, _in_ekb_bbox, _pct_deviation (incl. monotonicity) + - pure functions: _category_weight, _covered_region (реестр #3051), _pct_deviation + (incl. monotonicity) - _fetch_nearby_poi: qualitative POI ranking (unchanged behaviour from the old module) - compute_location_index: out-of-coverage degradation, insufficient-sample degradation (citywide AND local), radius-ladder expansion, explicit radius_m override, happy path @@ -48,22 +49,25 @@ def test_category_weight_unknown_and_none_fall_back_to_default() -> None: def test_in_ekb_bbox_center_is_inside() -> None: - assert lc._in_ekb_bbox(_LAT_IN_EKB, _LON_IN_EKB) is True + # #3051: _in_ekb_bbox → _covered_region (реестр регионов); граничные точки + # ниже — те же, что до реестра: продукт-ядро 66 сохранено байт-в-байт. + region = lc._covered_region(_LAT_IN_EKB, _LON_IN_EKB) + assert region is not None and region.code == 66 def test_in_ekb_bbox_bounds_are_inclusive() -> None: - assert lc._in_ekb_bbox(56.70, 60.50) is True - assert lc._in_ekb_bbox(56.95, 60.75) is True + assert lc._covered_region(56.70, 60.50) is not None + assert lc._covered_region(56.95, 60.75) is not None def test_in_ekb_bbox_outside_is_rejected() -> None: # Nizhny Tagil — same oblast (region_code=66), well outside the EKB product bbox. - assert lc._in_ekb_bbox(57.910, 59.970) is False + assert lc._covered_region(57.910, 59.970) is None # Just past each edge of the bbox. - assert lc._in_ekb_bbox(56.69, 60.60) is False - assert lc._in_ekb_bbox(56.96, 60.60) is False - assert lc._in_ekb_bbox(56.80, 60.49) is False - assert lc._in_ekb_bbox(56.80, 60.76) is False + assert lc._covered_region(56.69, 60.60) is None + assert lc._covered_region(56.96, 60.60) is None + assert lc._covered_region(56.80, 60.49) is None + assert lc._covered_region(56.80, 60.76) is None def test_pct_deviation_above_and_below_city_median() -> None: