From 0de5beeb647ab486794db5e632ca848abe8b73a2 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 25 Jul 2026 11:49:53 +0000 Subject: [PATCH] A7: enable pytest-asyncio (26 skipped async tests now run); fix stale distance assertion in test_geo_service --- backend/requirements.txt | 1 + backend/tests/test_geo_service.py | 5 ++++- pytest.ini | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 pytest.ini diff --git a/backend/requirements.txt b/backend/requirements.txt index 4ce9dcf..d2fb122 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -13,3 +13,4 @@ pydantic-settings==2.6.1 email-validator==2.1.0 psycopg2-binary==2.9.12 pytest==8.3.4 +pytest-asyncio==0.24.0 diff --git a/backend/tests/test_geo_service.py b/backend/tests/test_geo_service.py index 5606818..2eddacd 100644 --- a/backend/tests/test_geo_service.py +++ b/backend/tests/test_geo_service.py @@ -22,6 +22,7 @@ from services.geo_service import ( build_search_zones, DIRECTIONS, SEARCH_DISTANCES, + _build_search_distances, CACHE_DIR ) @@ -350,7 +351,9 @@ class TestBuildSearchZones: zones = await build_search_zones(53.9, 27.5, {}) distances_found = set(z.distance_km for z in zones) - expected_distances = set(d / 1000 for d in SEARCH_DISTANCES) + # build_search_zones derives distances from max_distance_km (default 3.0 km), + # not from the legacy SEARCH_DISTANCES constant. + expected_distances = set(d / 1000 for d in _build_search_distances(3.0)) assert distances_found == expected_distances @pytest.mark.asyncio diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..fe373f4 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +asyncio_mode = auto +testpaths = backend/tests +markers = + asyncio: async test powered by pytest-asyncio