feat(weather): add weather location search

This commit is contained in:
2026-04-22 12:58:56 +03:00
parent 3dd0a5410c
commit 94870a5c86
32 changed files with 550 additions and 152 deletions

View File

@@ -3,25 +3,27 @@ import datetime
import pytest
from gallery.painting.openweather.api import OpenWeatherApi
from gallery.painting.openweather.mock import OPENWEATHER_MOCK_DATA
from gallery.painting.openweather.openweather import Forecast
from gallery.painting.openweather.openweather import OpenWeather
from tests.data.openweather import OPENWEATHER_MOCK_SOURCE
@pytest.fixture(name="openweather_api", scope="module")
def openweather_api_fixture() -> OpenWeatherApi:
async def _get_location_forecast(location_id: str) -> Forecast:
return Forecast(**OPENWEATHER_MOCK_DATA.get_json("forecast"))
class MockOpenWeather(OpenWeather):
def __init__(self):
super().__init__("")
self._source = OPENWEATHER_MOCK_SOURCE
api = OpenWeatherApi()
api._get_location_forecast = _get_location_forecast
api.SOURCE = MockOpenWeather()
return api
async def test_day(openweather_api: OpenWeatherApi):
result = await openweather_api.get_day("orel-4432", datetime.date(2024, 8, 23))
result = await openweather_api.get_day("52.968498:36.0695", datetime.date(2024, 8, 23))
assert len(result.values) == 8
async def test_days(openweather_api: OpenWeatherApi):
result = await openweather_api.get_days("orel-4432", 10)
result = await openweather_api.get_days("52.968498:36.0695", 10)
assert len(result.values) == 6