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: