fix: геокодинг через Nominatim — корректные города по кириллице

This commit is contained in:
Maksim Totmin
2026-09-23 19:29:59 +07:00
parent 534ff9c5b0
commit cbae93cee4
3 changed files with 62 additions and 29 deletions
+10 -13
View File
@@ -18,17 +18,14 @@ import weather # noqa: E402
LOCATION = weather.Location("Казань", "Татарстан", "Россия", 55.7887, 49.1221)
GEOCODE_PAYLOAD = {
"results": [
{
"name": "Казань",
"admin1": "Татарстан",
"country": "Россия",
"latitude": 55.78874,
"longitude": 49.12214,
}
]
}
GEOCODE_PAYLOAD = [
{
"lat": "55.78874",
"lon": "49.12214",
"display_name": "Казань, городской округ Казань, Татарстан, Россия",
"address": {"city": "Казань", "state": "Татарстан", "country": "Россия"},
}
]
FORECAST_PAYLOAD = {
"properties": {
@@ -71,7 +68,7 @@ def test_geocode_empty_city_raises():
def test_geocode_not_found(monkeypatch):
monkeypatch.setattr(weather, "_get", lambda url, params: {"results": []})
monkeypatch.setattr(weather, "_get", lambda url, params: [])
with pytest.raises(weather.WeatherError) as exc:
weather.geocode("Абракадабрания")
assert "не найден" in exc.value.message
@@ -91,7 +88,7 @@ def test_geocode_is_cached(monkeypatch):
calls: list[str] = []
def fake_get(url, params):
calls.append(params["name"])
calls.append(params["q"])
return GEOCODE_PAYLOAD
monkeypatch.setattr(weather, "_get", fake_get)