test(3051): tests/services/test_location_index.py переведён на _covered_region
All checks were successful
CI Trade-In / changes (pull_request) Successful in 7s
CI / changes (pull_request) Successful in 9s
CI Trade-In / browser-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 / frontend-checks (pull_request) Has been skipped
CI / backend-tests (pull_request) Has been skipped
CI Trade-In / backend-tests (pull_request) Successful in 4m38s

CI поймал то, что мой локальный прогон пропустил: сьют в ПОДДИРЕКТОРИИ
tests/services/ звал удалённый _in_ekb_bbox. Граничные точки сохранены те же
(продукт-ядро 66 байт-в-байт), проверка дополнена кодом региона.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
bot-backend 2026-08-26 18:47:29 +05:00
parent 0529bb249c
commit 24369a6bf2

View file

@ -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: