test(yandexweather): add yandexweather tests

This commit is contained in:
2026-09-01 22:36:54 +03:00
parent 86879a3219
commit d6487facf4
3 changed files with 108 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
from pathlib import Path
from tests.common.mock import MockSource
YANDEXWEATHER_MOCK_SOURCE = MockSource(
Path(__file__).parent,
{
"details": "details.html",
"suggest": "suggest.json",
},
)
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
import datetime
import pytest
from gallery.painting.yandexweather.api import YandexWeatherApi
from tests.common.mock import create_mock_api
from tests.data.yandexweather import YANDEXWEATHER_MOCK_SOURCE
@pytest.fixture(name="yandexweather_api", scope="module")
def yandexweather_api_fixture() -> YandexWeatherApi:
return create_mock_api(YandexWeatherApi, YANDEXWEATHER_MOCK_SOURCE)
async def test_search(yandexweather_api: YandexWeatherApi):
result = await yandexweather_api.find_locations("test")
assert len(result) == 5
async def test_day(yandexweather_api: YandexWeatherApi):
result = await yandexweather_api.get_day("test", datetime.date.today())
assert len(result.values) == 4
async def test_days(yandexweather_api: YandexWeatherApi):
result = await yandexweather_api.get_days("test", 10)
assert len(result.values) == 10