guideCity/backend/tests/test_nearby.py

26 lines
766 B
Python
Raw Permalink Normal View History

"""Integration test — assumes the DB has been migrated and seeded
(see README: alembic upgrade head + seed_loader for all 3 place files)
before running `docker compose exec api pytest`.
"""
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_nearby_red_square_returns_at_least_five_places() -> None:
response = client.get(
"/api/v1/nearby",
params={"lat": 55.7539, "lon": 37.6208, "city_slug": "moscow", "lang": "ru", "length": "short"},
)
assert response.status_code == 200
body = response.json()
assert body["count"] >= 5
assert len(body["places"]) == body["count"]
distances = [p["distance_m"] for p in body["places"]]
assert distances == sorted(distances)