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 @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")) api = OpenWeatherApi() api._get_location_forecast = _get_location_forecast return api async def test_day(openweather_api: OpenWeatherApi): result = await openweather_api.get_day("orel-4432", 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) assert len(result.values) == 6