feat(weather): add weather location search
This commit is contained in:
0
tests/common/__init__.py
Normal file
0
tests/common/__init__.py
Normal file
17
tests/common/mock.py
Normal file
17
tests/common/mock.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from pathlib import Path
|
||||
|
||||
from gallery.sketch.source import ApiSource
|
||||
|
||||
|
||||
class MockSource(ApiSource):
|
||||
|
||||
def __init__(self, path: Path, mapping: dict[str, str]):
|
||||
super().__init__("")
|
||||
self._path = path
|
||||
self._mapping = mapping
|
||||
|
||||
async def request(self, endpoint: str) -> str:
|
||||
for pattern, filename in self._mapping.items():
|
||||
if pattern in endpoint:
|
||||
return (self._path / filename).read_text()
|
||||
raise ValueError(endpoint)
|
||||
6334
tests/data/gismeteo/10-days.html
Normal file
6334
tests/data/gismeteo/10-days.html
Normal file
File diff suppressed because one or more lines are too long
12
tests/data/gismeteo/__init__.py
Normal file
12
tests/data/gismeteo/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from pathlib import Path
|
||||
|
||||
from tests.common.mock import MockSource
|
||||
|
||||
GISMETEO_MOCK_SOURCE = MockSource(
|
||||
Path(__file__).parent,
|
||||
{
|
||||
"today": "today.html",
|
||||
"10-days": "10-days.html",
|
||||
"mq/city/q": "mq_city_q.json",
|
||||
},
|
||||
)
|
||||
400
tests/data/gismeteo/mq_city_q.json
Normal file
400
tests/data/gismeteo/mq_city_q.json
Normal file
@@ -0,0 +1,400 @@
|
||||
{
|
||||
"meta": { "status": true },
|
||||
"data": [
|
||||
{
|
||||
"id": 4432,
|
||||
"kind": "M",
|
||||
"slug": "orel",
|
||||
"coordinates": { "latitude": 52.968498, "longitude": 36.0695 },
|
||||
"obsStationId": 11948,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 156, "slug": "russia", "code": "RU" },
|
||||
"district": { "id": 253, "slug": "oryol-oblast" },
|
||||
"subdistrict": { "id": 4728, "slug": "urban-district-city-oryol" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": { "name": "Орловская область", "nameP": "в Орловской области", "nameR": "Орловской области" },
|
||||
"subdistrict": {
|
||||
"name": "городской округ город Орёл",
|
||||
"nameP": "в городском округе города Орёл",
|
||||
"nameR": "городского округа города Орёл"
|
||||
}
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": { "name": "Орловская область", "nameP": "в Орловской области", "nameR": "Орловской области" },
|
||||
"subdistrict": {
|
||||
"name": "городской округ город Орёл",
|
||||
"nameP": "в городском округе города Орёл",
|
||||
"nameR": "городского округа города Орёл"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 13074,
|
||||
"kind": "A",
|
||||
"slug": "orel-yuzhnyy-im-i-s-turgeneva",
|
||||
"coordinates": { "latitude": 52.935001, "longitude": 36.001671 },
|
||||
"obsStationId": 11948,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 156, "slug": "russia", "code": "RU" },
|
||||
"district": { "id": 253, "slug": "oryol-oblast" },
|
||||
"subdistrict": { "id": 4728, "slug": "urban-district-city-oryol" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орел / Южный им. И. С. Тургенева", "nameP": "Орел / Южный им. И. С. Тургенева" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": { "name": "Орловская область", "nameP": "в Орловской области", "nameR": "Орловской области" },
|
||||
"subdistrict": {
|
||||
"name": "городской округ город Орёл",
|
||||
"nameP": "в городском округе города Орёл",
|
||||
"nameR": "городского округа города Орёл"
|
||||
}
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орел / Южный им. И. С. Тургенева", "nameP": "Орел / Южный им. И. С. Тургенева" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": { "name": "Орловская область", "nameP": "в Орловской области", "nameR": "Орловской области" },
|
||||
"subdistrict": {
|
||||
"name": "городской округ город Орёл",
|
||||
"nameP": "в городском округе города Орёл",
|
||||
"nameR": "городского округа города Орёл"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 112316,
|
||||
"kind": "T",
|
||||
"slug": "orel",
|
||||
"coordinates": { "latitude": 52.0172, "longitude": 30.849199 },
|
||||
"obsStationId": 12921,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 19, "slug": "belarus", "code": "BY" },
|
||||
"district": { "id": 346, "slug": "gomel-region" },
|
||||
"subdistrict": { "id": 1828, "slug": "loyev-district" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Беларусь", "nameP": "в Беларуси", "nameR": "Беларуси" },
|
||||
"district": { "name": "Гомельская область", "nameP": "в Гомельской области", "nameR": "Гомельской области" },
|
||||
"subdistrict": { "name": "Лоевский район", "nameP": "в Лоевском районе", "nameR": "Лоевского района" }
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Беларусь", "nameP": "в Беларуси", "nameR": "Беларуси" },
|
||||
"district": { "name": "Гомельская область", "nameP": "в Гомельской области", "nameR": "Гомельской области" },
|
||||
"subdistrict": { "name": "Лоевский район", "nameP": "в Лоевском районе", "nameR": "Лоевского района" }
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 178290,
|
||||
"kind": "T",
|
||||
"slug": "orel",
|
||||
"coordinates": { "latitude": 58.799999, "longitude": 34.453701 },
|
||||
"obsStationId": 11657,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 156, "slug": "russia", "code": "RU" },
|
||||
"district": { "id": 248, "slug": "novgorod-oblast" },
|
||||
"subdistrict": { "id": 2857, "slug": "municipal-district-khvoyninsky" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": {
|
||||
"name": "Новгородская область",
|
||||
"nameP": "в Новгородской области",
|
||||
"nameR": "Новгородской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "муниципальный округ Хвойнинский",
|
||||
"nameP": "в муниципальном округе Хвойнинском",
|
||||
"nameR": "муниципального округа Хвойнинского"
|
||||
}
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": {
|
||||
"name": "Новгородская область",
|
||||
"nameP": "в Новгородской области",
|
||||
"nameR": "Новгородской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "муниципальный округ Хвойнинский",
|
||||
"nameP": "в муниципальном округе Хвойнинском",
|
||||
"nameR": "муниципального округа Хвойнинского"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 112830,
|
||||
"kind": "T",
|
||||
"slug": "orel",
|
||||
"coordinates": { "latitude": 52.182499, "longitude": 30.4349 },
|
||||
"obsStationId": 12920,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 19, "slug": "belarus", "code": "BY" },
|
||||
"district": { "id": 346, "slug": "gomel-region" },
|
||||
"subdistrict": { "id": 1833, "slug": "rechytsa-district" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Беларусь", "nameP": "в Беларуси", "nameR": "Беларуси" },
|
||||
"district": { "name": "Гомельская область", "nameP": "в Гомельской области", "nameR": "Гомельской области" },
|
||||
"subdistrict": { "name": "Речицкий район", "nameP": "в Речицком районе", "nameR": "Речицкого района" }
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Беларусь", "nameP": "в Беларуси", "nameR": "Беларуси" },
|
||||
"district": { "name": "Гомельская область", "nameP": "в Гомельской области", "nameR": "Гомельской области" },
|
||||
"subdistrict": { "name": "Речицкий район", "nameP": "в Речицком районе", "nameR": "Речицкого района" }
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 97816,
|
||||
"kind": "T",
|
||||
"slug": "orilske",
|
||||
"coordinates": { "latitude": 49.088799, "longitude": 36.228401 },
|
||||
"obsStationId": 13147,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 198, "slug": "ukraine", "code": "UA" },
|
||||
"district": { "id": 335, "slug": "kharkiv-oblast" },
|
||||
"subdistrict": { "id": 1646, "slug": "berestyn-district" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орельское", "nameP": "в Орельском" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Харьковская область",
|
||||
"nameP": "в Харьковской области",
|
||||
"nameR": "Харьковской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "Берестинский район",
|
||||
"nameP": "в Берестинском районе",
|
||||
"nameR": "Берестинского района"
|
||||
}
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орельское", "nameP": "в Орельском" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Харьковская область",
|
||||
"nameP": "в Харьковской области",
|
||||
"nameR": "Харьковской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "Берестинский район",
|
||||
"nameP": "в Берестинском районе",
|
||||
"nameR": "Берестинского района"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 97619,
|
||||
"kind": "T",
|
||||
"slug": "orilka",
|
||||
"coordinates": { "latitude": 48.980499, "longitude": 36.0075 },
|
||||
"obsStationId": 13147,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 198, "slug": "ukraine", "code": "UA" },
|
||||
"district": { "id": 335, "slug": "kharkiv-oblast" },
|
||||
"subdistrict": { "id": 1649, "slug": "lozivskyi-district" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орелька", "nameP": "в Орельке" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Харьковская область",
|
||||
"nameP": "в Харьковской области",
|
||||
"nameR": "Харьковской области"
|
||||
},
|
||||
"subdistrict": { "name": "Лозовский район", "nameP": "в Лозовском районе", "nameR": "Лозовского района" }
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орелька", "nameP": "в Орельке" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Харьковская область",
|
||||
"nameP": "в Харьковской области",
|
||||
"nameR": "Харьковской области"
|
||||
},
|
||||
"subdistrict": { "name": "Лозовский район", "nameP": "в Лозовском районе", "nameR": "Лозовского района" }
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 78141,
|
||||
"kind": "T",
|
||||
"slug": "orilka",
|
||||
"coordinates": { "latitude": 48.945999, "longitude": 35.689098 },
|
||||
"obsStationId": 13158,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 198, "slug": "ukraine", "code": "UA" },
|
||||
"district": { "id": 319, "slug": "dnipropetrovsk-oblast" },
|
||||
"subdistrict": { "id": 1184, "slug": "samarivskyi-district" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орелька", "nameP": "в Орельке" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Днепропетровская область",
|
||||
"nameP": "в Днепропетровской области",
|
||||
"nameR": "Днепропетровской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "Самаровский район",
|
||||
"nameP": "в Самаровском районе",
|
||||
"nameR": "Самаровского района"
|
||||
}
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орелька", "nameP": "в Орельке" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Днепропетровская область",
|
||||
"nameP": "в Днепропетровской области",
|
||||
"nameR": "Днепропетровской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "Самаровский район",
|
||||
"nameP": "в Самаровском районе",
|
||||
"nameR": "Самаровского района"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 77735,
|
||||
"kind": "T",
|
||||
"slug": "orilske",
|
||||
"coordinates": { "latitude": 48.587799, "longitude": 34.8111 },
|
||||
"obsStationId": 13158,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 198, "slug": "ukraine", "code": "UA" },
|
||||
"district": { "id": 319, "slug": "dnipropetrovsk-oblast" },
|
||||
"subdistrict": { "id": 1178, "slug": "dniprovskyi-district" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орельское (Партизанское)", "nameP": "в Орельском (Партизанском)" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Днепропетровская область",
|
||||
"nameP": "в Днепропетровской области",
|
||||
"nameR": "Днепропетровской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "Днепровский район",
|
||||
"nameP": "в Днепровском районе",
|
||||
"nameR": "Днепровского района"
|
||||
}
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орельское (Партизанское)", "nameP": "в Орельском (Партизанском)" },
|
||||
"country": { "name": "Украина", "nameP": "на Украине", "nameR": "Украины" },
|
||||
"district": {
|
||||
"name": "Днепропетровская область",
|
||||
"nameP": "в Днепропетровской области",
|
||||
"nameR": "Днепропетровской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "Днепровский район",
|
||||
"nameP": "в Днепровском районе",
|
||||
"nameR": "Днепровского района"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
},
|
||||
{
|
||||
"id": 171956,
|
||||
"kind": "T",
|
||||
"slug": "orel",
|
||||
"coordinates": { "latitude": 55.516499, "longitude": 44.0658 },
|
||||
"obsStationId": 11899,
|
||||
"timeZone": 180,
|
||||
"country": { "id": 156, "slug": "russia", "code": "RU" },
|
||||
"district": { "id": 266, "slug": "nizhny-novgorod-oblast" },
|
||||
"subdistrict": { "id": 2796, "slug": "municipal-district-vadsky" },
|
||||
"translations": {
|
||||
"ru": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": {
|
||||
"name": "Нижегородская область",
|
||||
"nameP": "в Нижегородской области",
|
||||
"nameR": "Нижегородской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "муниципальный округ Вадский",
|
||||
"nameP": "в муниципальном округе Вадском",
|
||||
"nameR": "муниципального округа Вадского"
|
||||
}
|
||||
},
|
||||
"kk": {
|
||||
"city": { "name": "Орел", "nameP": "в Орле" },
|
||||
"country": { "name": "Россия", "nameP": "в России", "nameR": "России" },
|
||||
"district": {
|
||||
"name": "Нижегородская область",
|
||||
"nameP": "в Нижегородской области",
|
||||
"nameR": "Нижегородской области"
|
||||
},
|
||||
"subdistrict": {
|
||||
"name": "муниципальный округ Вадский",
|
||||
"nameP": "в муниципальном округе Вадском",
|
||||
"nameR": "муниципального округа Вадского"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visitCount": 0,
|
||||
"options": { "altitude": 0, "mrlExists": false, "significantHeightDiff": false, "landSeaMask": 0 },
|
||||
"meta": { "nowcast": true, "allergy": { "birch": true, "grass": true, "ragweed": true } },
|
||||
"redirectUrl": {}
|
||||
}
|
||||
],
|
||||
"error": null
|
||||
}
|
||||
6114
tests/data/gismeteo/today.html
Normal file
6114
tests/data/gismeteo/today.html
Normal file
File diff suppressed because one or more lines are too long
10
tests/data/matchtv/__init__.py
Normal file
10
tests/data/matchtv/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pathlib import Path
|
||||
|
||||
from tests.common.mock import MockSource
|
||||
|
||||
MATCHTV_MOCK_SOURCE = MockSource(
|
||||
Path(__file__).parent,
|
||||
{
|
||||
"test": "test.html",
|
||||
},
|
||||
)
|
||||
2
tests/data/matchtv/test.html
Normal file
2
tests/data/matchtv/test.html
Normal file
File diff suppressed because one or more lines are too long
10
tests/data/openweather/__init__.py
Normal file
10
tests/data/openweather/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pathlib import Path
|
||||
|
||||
from tests.common.mock import MockSource
|
||||
|
||||
OPENWEATHER_MOCK_SOURCE = MockSource(
|
||||
Path(__file__).parent,
|
||||
{
|
||||
"forecast": "forecast.json",
|
||||
},
|
||||
)
|
||||
1139
tests/data/openweather/forecast.json
Normal file
1139
tests/data/openweather/forecast.json
Normal file
File diff suppressed because it is too large
Load Diff
10
tests/data/yandextv/__init__.py
Normal file
10
tests/data/yandextv/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pathlib import Path
|
||||
|
||||
from tests.common.mock import MockSource
|
||||
|
||||
YANDEXTV_MOCK_SOURCE = MockSource(
|
||||
Path(__file__).parent,
|
||||
{
|
||||
"test": "test.html",
|
||||
},
|
||||
)
|
||||
88
tests/data/yandextv/test.html
Normal file
88
tests/data/yandextv/test.html
Normal file
File diff suppressed because one or more lines are too long
@@ -3,20 +3,21 @@ import datetime
|
||||
import pytest
|
||||
|
||||
from gallery.painting.gismeteo.api import GismeteoApi
|
||||
from gallery.painting.gismeteo.mock import GISMETEO_MOCK_DATA
|
||||
from tests.data.gismeteo import GISMETEO_MOCK_SOURCE
|
||||
|
||||
|
||||
@pytest.fixture(name="gismeteo_api", scope="module")
|
||||
def gismeteo_api_fixture() -> GismeteoApi:
|
||||
class MockSource:
|
||||
async def request(self, endpoint: str):
|
||||
return GISMETEO_MOCK_DATA.get_html(endpoint.split("/")[-1])
|
||||
|
||||
api = GismeteoApi()
|
||||
api.SOURCE = MockSource()
|
||||
api.SOURCE = GISMETEO_MOCK_SOURCE
|
||||
return api
|
||||
|
||||
|
||||
async def test_search(gismeteo_api: GismeteoApi):
|
||||
result = await gismeteo_api.find_locations("test")
|
||||
assert len(result) == 10
|
||||
|
||||
|
||||
async def test_day(gismeteo_api: GismeteoApi):
|
||||
result = await gismeteo_api.get_day("test", datetime.date.today())
|
||||
assert len(result.values) == 8
|
||||
|
||||
@@ -3,18 +3,14 @@ import datetime
|
||||
import pytest
|
||||
|
||||
from gallery.painting.matchtv.api import MatchTvApi
|
||||
from gallery.painting.matchtv.mock import MATCHTV_MOCK_DATA
|
||||
from gallery.sketch.schedule.model import ChannelId
|
||||
from tests.data.matchtv import MATCHTV_MOCK_SOURCE
|
||||
|
||||
|
||||
@pytest.fixture(name="matchtv_api", scope="module")
|
||||
def matchtv_api_fixture() -> MatchTvApi:
|
||||
class MockSource:
|
||||
async def request(self, endpoint: str):
|
||||
return MATCHTV_MOCK_DATA.get_html(endpoint.split("/")[1].split("?")[0])
|
||||
|
||||
api = MatchTvApi()
|
||||
api.SOURCE = MockSource()
|
||||
api.SOURCE = MATCHTV_MOCK_SOURCE
|
||||
return api
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,19 +3,14 @@ import datetime
|
||||
import pytest
|
||||
|
||||
from gallery.painting.yandextv.api import CHANNELS_MAP, YandexTvApi
|
||||
from gallery.painting.yandextv.mock import YANDEXTV_MOCK_DATA
|
||||
from gallery.sketch.schedule.model import ChannelId
|
||||
from tests.data.yandextv import YANDEXTV_MOCK_SOURCE
|
||||
|
||||
|
||||
@pytest.fixture(name="yandextv_api", scope="module")
|
||||
def yandextv_api_fixture() -> YandexTvApi:
|
||||
class MockSource:
|
||||
async def request(self, endpoint: str):
|
||||
return YANDEXTV_MOCK_DATA.get_html(endpoint.split("/")[1].split("?")[0])
|
||||
|
||||
api = YandexTvApi()
|
||||
api.SOURCE = MockSource()
|
||||
|
||||
api.SOURCE = YANDEXTV_MOCK_SOURCE
|
||||
CHANNELS_MAP[ChannelId("test")] = "test"
|
||||
return api
|
||||
|
||||
|
||||
Reference in New Issue
Block a user