feat(weather): add openweather api

This commit is contained in:
2024-08-25 23:28:49 +03:00
parent d3ef03a6a0
commit 3e80ccb0df
25 changed files with 1636 additions and 75 deletions

View File

@@ -0,0 +1,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
@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