Files
gallery/gismeteo/mock/__init__.py

26 lines
554 B
Python

import json
from pathlib import Path
from typing import List
import dateparser
from gismeteo.api import WeatherValue
class MockData:
@property
def html(self) -> str:
return (Path(__file__).parent / "data/weather.html").read_text()
@property
def values(self) -> List[WeatherValue]:
data = json.loads((Path(__file__).parent / "data/weather.json").read_text())
return [
WeatherValue(**{**item, "date": dateparser.parse(item["date"])})
for item in data
]
MOCK_DATA = MockData()