mirror of
https://github.com/jdejaegh/irm-kmi-api.git
synced 2025-06-26 20:05:40 +02:00
Breaking: remove prefix from data types
This commit is contained in:
parent
9641b4219b
commit
c06f1c8972
8 changed files with 107 additions and 107 deletions
|
@ -17,8 +17,8 @@ import async_timeout
|
|||
from .const import MAP_WARNING_ID_TO_SLUG as SLUG_MAP, WWEVOL_TO_ENUM_MAP
|
||||
from .const import STYLE_TO_PARAM_MAP, WEEKDAYS
|
||||
from .data import (AnimationFrameData, CurrentWeatherData, Forecast,
|
||||
IrmKmiForecast, IrmKmiRadarForecast, RadarAnimationData,
|
||||
WarningData, IrmKmiRadarStyle)
|
||||
ExtendedForecast, IrmKmiRadarForecast, RadarAnimationData,
|
||||
WarningData, RadarStyle)
|
||||
from .pollen import PollenParser
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -344,7 +344,7 @@ class IrmKmiApiClientHa(IrmKmiApiClient):
|
|||
|
||||
return forecasts
|
||||
|
||||
def get_daily_forecast(self, tz: ZoneInfo, lang: str) -> List[IrmKmiForecast]:
|
||||
def get_daily_forecast(self, tz: ZoneInfo, lang: str) -> List[ExtendedForecast]:
|
||||
"""
|
||||
Parse the API data we currently have to build the daily forecast list.
|
||||
|
||||
|
@ -416,7 +416,7 @@ class IrmKmiApiClientHa(IrmKmiApiClient):
|
|||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
forecast = IrmKmiForecast(
|
||||
forecast = ExtendedForecast(
|
||||
datetime=(forecast_day.strftime('%Y-%m-%d')),
|
||||
condition=self._cdt_map.get((f.get('ww1', None), f.get('dayNight', None)), None),
|
||||
condition_2=self._cdt_map.get((f.get('ww2', None), f.get('dayNight', None)), None),
|
||||
|
@ -444,7 +444,7 @@ class IrmKmiApiClientHa(IrmKmiApiClient):
|
|||
|
||||
return forecasts
|
||||
|
||||
def get_animation_data(self, tz: ZoneInfo, lang: str, style: IrmKmiRadarStyle, dark_mode: bool) -> RadarAnimationData:
|
||||
def get_animation_data(self, tz: ZoneInfo, lang: str, style: RadarStyle, dark_mode: bool) -> RadarAnimationData:
|
||||
"""
|
||||
Get all the image URLs and create the radar animation data object.
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
from typing import Final
|
||||
|
||||
from .data import IrmKmiConditionEvol, IrmKmiRadarStyle, IrmKmiPollenLevels
|
||||
from .data import ConditionEvol, RadarStyle, PollenLevels
|
||||
|
||||
POLLEN_LEVEL_TO_COLOR = {
|
||||
'null': IrmKmiPollenLevels.GREEN,
|
||||
'low': IrmKmiPollenLevels.YELLOW,
|
||||
'moderate': IrmKmiPollenLevels.ORANGE,
|
||||
'high': IrmKmiPollenLevels.RED,
|
||||
'very high': IrmKmiPollenLevels.PURPLE,
|
||||
'active': IrmKmiPollenLevels.ACTIVE
|
||||
'null': PollenLevels.GREEN,
|
||||
'low': PollenLevels.YELLOW,
|
||||
'moderate': PollenLevels.ORANGE,
|
||||
'high': PollenLevels.RED,
|
||||
'very high': PollenLevels.PURPLE,
|
||||
'active': PollenLevels.ACTIVE
|
||||
}
|
||||
|
||||
WEEKDAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
||||
|
||||
STYLE_TO_PARAM_MAP: Final = {
|
||||
IrmKmiRadarStyle.OPTION_STYLE_STD: 1,
|
||||
IrmKmiRadarStyle.OPTION_STYLE_CONTRAST: 2,
|
||||
IrmKmiRadarStyle.OPTION_STYLE_YELLOW_RED: 3,
|
||||
IrmKmiRadarStyle.OPTION_STYLE_SATELLITE: 4
|
||||
RadarStyle.OPTION_STYLE_STD: 1,
|
||||
RadarStyle.OPTION_STYLE_CONTRAST: 2,
|
||||
RadarStyle.OPTION_STYLE_YELLOW_RED: 3,
|
||||
RadarStyle.OPTION_STYLE_SATELLITE: 4
|
||||
}
|
||||
|
||||
MAP_WARNING_ID_TO_SLUG: Final = {
|
||||
|
@ -34,7 +34,7 @@ MAP_WARNING_ID_TO_SLUG: Final = {
|
|||
17: 'coldspell'}
|
||||
|
||||
WWEVOL_TO_ENUM_MAP: Final = {
|
||||
None: IrmKmiConditionEvol.STABLE,
|
||||
0: IrmKmiConditionEvol.ONE_WAY,
|
||||
1: IrmKmiConditionEvol.TWO_WAYS
|
||||
None: ConditionEvol.STABLE,
|
||||
0: ConditionEvol.ONE_WAY,
|
||||
1: ConditionEvol.TWO_WAYS
|
||||
}
|
|
@ -36,7 +36,7 @@ class Forecast(TypedDict, total=False):
|
|||
is_daytime: bool | None # Mandatory to use with forecast_twice_daily
|
||||
|
||||
|
||||
class IrmKmiConditionEvol(Enum):
|
||||
class ConditionEvol(Enum):
|
||||
"""Possible state for evolution between weather conditions"""
|
||||
|
||||
ONE_WAY = 'one_way'
|
||||
|
@ -44,7 +44,7 @@ class IrmKmiConditionEvol(Enum):
|
|||
STABLE = 'stable'
|
||||
|
||||
|
||||
class IrmKmiRadarStyle(Enum):
|
||||
class RadarStyle(Enum):
|
||||
"""Possible style for the rain radar"""
|
||||
|
||||
OPTION_STYLE_STD = 'standard_style'
|
||||
|
@ -53,7 +53,7 @@ class IrmKmiRadarStyle(Enum):
|
|||
OPTION_STYLE_SATELLITE = 'satellite_style'
|
||||
|
||||
|
||||
class IrmKmiPollenNames(Enum):
|
||||
class PollenNames(Enum):
|
||||
"""Pollens names from the API"""
|
||||
|
||||
ALDER = 'alder'
|
||||
|
@ -65,7 +65,7 @@ class IrmKmiPollenNames(Enum):
|
|||
OAK = 'oak'
|
||||
|
||||
|
||||
class IrmKmiPollenLevels(Enum):
|
||||
class PollenLevels(Enum):
|
||||
"""Possible pollen levels"""
|
||||
|
||||
NONE = 'none'
|
||||
|
@ -77,11 +77,11 @@ class IrmKmiPollenLevels(Enum):
|
|||
PURPLE = 'purple'
|
||||
|
||||
|
||||
class IrmKmiForecast(Forecast, total=False):
|
||||
class ExtendedForecast(Forecast, total=False):
|
||||
"""Forecast class with additional attributes for IRM KMI"""
|
||||
|
||||
condition_2: str | None
|
||||
condition_evol: IrmKmiConditionEvol | None
|
||||
condition_evol: ConditionEvol | None
|
||||
text: str | None
|
||||
sunrise: str | None
|
||||
sunset: str | None
|
||||
|
|
|
@ -4,7 +4,7 @@ import xml.etree.ElementTree as ET
|
|||
from typing import List, Dict
|
||||
|
||||
from .const import POLLEN_LEVEL_TO_COLOR
|
||||
from .data import IrmKmiPollenNames, IrmKmiPollenLevels
|
||||
from .data import PollenNames, PollenLevels
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -22,7 +22,7 @@ class PollenParser:
|
|||
):
|
||||
self._xml = xml_string
|
||||
|
||||
def get_pollen_data(self) -> Dict[IrmKmiPollenNames, IrmKmiPollenLevels | None]:
|
||||
def get_pollen_data(self) -> Dict[PollenNames, PollenLevels | None]:
|
||||
"""
|
||||
Parse the SVG and extract the pollen data from the image.
|
||||
If an error occurs, return the default value.
|
||||
|
@ -40,7 +40,7 @@ class PollenParser:
|
|||
elements: List[ET.Element] = self._extract_elements(root)
|
||||
|
||||
pollens = {e.attrib.get('x', None): self._get_txt(e).lower()
|
||||
for e in elements if 'tspan' in e.tag and str(self._get_txt(e)).lower() in IrmKmiPollenNames}
|
||||
for e in elements if 'tspan' in e.tag and str(self._get_txt(e)).lower() in PollenNames}
|
||||
|
||||
pollen_levels = {e.attrib.get('x', None): POLLEN_LEVEL_TO_COLOR[self._get_txt(e)]
|
||||
for e in elements if 'tspan' in e.tag and self._get_txt(e) in POLLEN_LEVEL_TO_COLOR}
|
||||
|
@ -53,7 +53,7 @@ class PollenParser:
|
|||
for position, pollen in pollens.items():
|
||||
# Check if pollen is a known one
|
||||
try:
|
||||
pollen: IrmKmiPollenNames = IrmKmiPollenNames(pollen)
|
||||
pollen: PollenNames = PollenNames(pollen)
|
||||
except ValueError:
|
||||
_LOGGER.warning(f'Unknown pollen name {pollen}')
|
||||
continue
|
||||
|
@ -62,7 +62,7 @@ class PollenParser:
|
|||
pollen_data[pollen] = pollen_levels[position]
|
||||
_LOGGER.debug(f"{pollen.value} is {pollen_data[pollen]} according to text")
|
||||
# If text is 'active' or if there is no text, check the dot as a fallback
|
||||
if pollen_data[pollen] not in {IrmKmiPollenLevels.NONE, IrmKmiPollenLevels.ACTIVE}:
|
||||
if pollen_data[pollen] not in {PollenLevels.NONE, PollenLevels.ACTIVE}:
|
||||
_LOGGER.debug(f"{pollen} trusting text")
|
||||
else:
|
||||
for dot in level_dots:
|
||||
|
@ -72,15 +72,15 @@ class PollenParser:
|
|||
pass
|
||||
else:
|
||||
if 24 <= relative_x_position <= 34:
|
||||
pollen_data[pollen] = IrmKmiPollenLevels.GREEN
|
||||
pollen_data[pollen] = PollenLevels.GREEN
|
||||
elif 13 <= relative_x_position <= 23:
|
||||
pollen_data[pollen] = IrmKmiPollenLevels.YELLOW
|
||||
pollen_data[pollen] = PollenLevels.YELLOW
|
||||
elif -5 <= relative_x_position <= 5:
|
||||
pollen_data[pollen] = IrmKmiPollenLevels.ORANGE
|
||||
pollen_data[pollen] = PollenLevels.ORANGE
|
||||
elif -23 <= relative_x_position <= -13:
|
||||
pollen_data[pollen] = IrmKmiPollenLevels.RED
|
||||
pollen_data[pollen] = PollenLevels.RED
|
||||
elif -34 <= relative_x_position <= -24:
|
||||
pollen_data[pollen] = IrmKmiPollenLevels.PURPLE
|
||||
pollen_data[pollen] = PollenLevels.PURPLE
|
||||
|
||||
_LOGGER.debug(f"{pollen.value} is {pollen_data[pollen]} according to dot")
|
||||
|
||||
|
@ -88,19 +88,19 @@ class PollenParser:
|
|||
return pollen_data
|
||||
|
||||
@staticmethod
|
||||
def get_default_data() -> Dict[IrmKmiPollenNames, IrmKmiPollenLevels | None]:
|
||||
def get_default_data() -> Dict[PollenNames, PollenLevels | None]:
|
||||
"""Return all the known pollen with 'none' value"""
|
||||
return {k: IrmKmiPollenLevels.NONE for k in IrmKmiPollenNames}
|
||||
return {k: PollenLevels.NONE for k in PollenNames}
|
||||
|
||||
@staticmethod
|
||||
def get_unavailable_data() -> Dict[IrmKmiPollenNames, IrmKmiPollenLevels | None]:
|
||||
def get_unavailable_data() -> Dict[PollenNames, PollenLevels | None]:
|
||||
"""Return all the known pollen with None value"""
|
||||
return {k: None for k in IrmKmiPollenNames}
|
||||
return {k: None for k in PollenNames}
|
||||
|
||||
@staticmethod
|
||||
def get_option_values() -> List[IrmKmiPollenLevels]:
|
||||
def get_option_values() -> List[PollenLevels]:
|
||||
"""List all the values that the pollen can have"""
|
||||
return list(POLLEN_LEVEL_TO_COLOR.values()) + [IrmKmiPollenLevels.NONE]
|
||||
return list(POLLEN_LEVEL_TO_COLOR.values()) + [PollenLevels.NONE]
|
||||
|
||||
@staticmethod
|
||||
def _extract_elements(root) -> List[ET.Element]:
|
||||
|
|
|
@ -12,7 +12,7 @@ from svgwrite.animate import Animate
|
|||
from svgwrite.container import FONT_TEMPLATE
|
||||
|
||||
from .api import IrmKmiApiClient, IrmKmiApiError
|
||||
from .data import AnimationFrameData, RadarAnimationData, IrmKmiRadarStyle
|
||||
from .data import AnimationFrameData, RadarAnimationData, RadarStyle
|
||||
from .resources import be_black, be_satellite, be_white, nl, roboto
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -24,7 +24,7 @@ class RainGraph:
|
|||
def __init__(self,
|
||||
animation_data: RadarAnimationData,
|
||||
country: str,
|
||||
style: IrmKmiRadarStyle,
|
||||
style: RadarStyle,
|
||||
dark_mode: bool = False,
|
||||
tz: datetime.tzinfo = None,
|
||||
svg_width: float = 640,
|
||||
|
@ -431,7 +431,7 @@ class RainGraph:
|
|||
def _get_background_png_b64(self) -> str:
|
||||
if self._country == 'NL':
|
||||
return nl.nl_b64
|
||||
elif self._style == IrmKmiRadarStyle.OPTION_STYLE_SATELLITE:
|
||||
elif self._style == RadarStyle.OPTION_STYLE_SATELLITE:
|
||||
return be_satellite.be_satelitte_b64
|
||||
elif self._dark_mode:
|
||||
return be_black.be_black_b64
|
||||
|
|
|
@ -3,7 +3,7 @@ from zoneinfo import ZoneInfo
|
|||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from irm_kmi_api.data import IrmKmiForecast, IrmKmiConditionEvol
|
||||
from irm_kmi_api.data import ExtendedForecast, ConditionEvol
|
||||
from tests.conftest import get_api_with_data
|
||||
from tests.const import ATTR_CONDITION_PARTLYCLOUDY
|
||||
|
||||
|
@ -19,11 +19,11 @@ async def test_daily_forecast() -> None:
|
|||
assert len(result) == 8
|
||||
assert result[0]['datetime'] == '2023-12-26'
|
||||
assert not result[0]['is_daytime']
|
||||
expected = IrmKmiForecast(
|
||||
expected = ExtendedForecast(
|
||||
datetime='2023-12-27',
|
||||
condition=ATTR_CONDITION_PARTLYCLOUDY,
|
||||
condition_2=None,
|
||||
condition_evol=IrmKmiConditionEvol.TWO_WAYS,
|
||||
condition_evol=ConditionEvol.TWO_WAYS,
|
||||
native_precipitation=0,
|
||||
native_temperature=9,
|
||||
native_templow=4,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from irm_kmi_api.data import IrmKmiPollenNames, IrmKmiPollenLevels
|
||||
from irm_kmi_api.data import PollenNames, PollenLevels
|
||||
from irm_kmi_api.pollen import PollenParser
|
||||
from tests.conftest import get_api_with_data, load_fixture
|
||||
|
||||
|
@ -10,56 +10,56 @@ def test_svg_pollen_parsing():
|
|||
with open("tests/fixtures/pollen.svg", "r") as file:
|
||||
svg_data = file.read()
|
||||
data = PollenParser(svg_data).get_pollen_data()
|
||||
assert data == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.PURPLE,
|
||||
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE}
|
||||
assert data == {PollenNames.BIRCH: PollenLevels.NONE,
|
||||
PollenNames.OAK: PollenLevels.NONE,
|
||||
PollenNames.HAZEL: PollenLevels.NONE,
|
||||
PollenNames.MUGWORT: PollenLevels.NONE,
|
||||
PollenNames.ALDER: PollenLevels.NONE,
|
||||
PollenNames.GRASSES: PollenLevels.PURPLE,
|
||||
PollenNames.ASH: PollenLevels.NONE}
|
||||
|
||||
def test_svg_two_pollen_parsing():
|
||||
with open("tests/fixtures/new_two_pollens.svg", "r") as file:
|
||||
svg_data = file.read()
|
||||
data = PollenParser(svg_data).get_pollen_data()
|
||||
assert data == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.ACTIVE,
|
||||
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.RED,
|
||||
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE}
|
||||
assert data == {PollenNames.BIRCH: PollenLevels.NONE,
|
||||
PollenNames.OAK: PollenLevels.NONE,
|
||||
PollenNames.HAZEL: PollenLevels.NONE,
|
||||
PollenNames.MUGWORT: PollenLevels.ACTIVE,
|
||||
PollenNames.ALDER: PollenLevels.NONE,
|
||||
PollenNames.GRASSES: PollenLevels.RED,
|
||||
PollenNames.ASH: PollenLevels.NONE}
|
||||
|
||||
def test_svg_two_pollen_parsing_2025_update():
|
||||
with open("tests/fixtures/pollens-2025.svg", "r") as file:
|
||||
svg_data = file.read()
|
||||
data = PollenParser(svg_data).get_pollen_data()
|
||||
assert data == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.ACTIVE,
|
||||
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.GREEN,
|
||||
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE}
|
||||
assert data == {PollenNames.BIRCH: PollenLevels.NONE,
|
||||
PollenNames.OAK: PollenLevels.NONE,
|
||||
PollenNames.HAZEL: PollenLevels.ACTIVE,
|
||||
PollenNames.MUGWORT: PollenLevels.NONE,
|
||||
PollenNames.ALDER: PollenLevels.GREEN,
|
||||
PollenNames.GRASSES: PollenLevels.NONE,
|
||||
PollenNames.ASH: PollenLevels.NONE}
|
||||
|
||||
def test_pollen_options():
|
||||
assert set(PollenParser.get_option_values()) == {IrmKmiPollenLevels.GREEN,
|
||||
IrmKmiPollenLevels.YELLOW,
|
||||
IrmKmiPollenLevels.ORANGE,
|
||||
IrmKmiPollenLevels.RED,
|
||||
IrmKmiPollenLevels.PURPLE,
|
||||
IrmKmiPollenLevels.ACTIVE,
|
||||
IrmKmiPollenLevels.NONE}
|
||||
assert set(PollenParser.get_option_values()) == {PollenLevels.GREEN,
|
||||
PollenLevels.YELLOW,
|
||||
PollenLevels.ORANGE,
|
||||
PollenLevels.RED,
|
||||
PollenLevels.PURPLE,
|
||||
PollenLevels.ACTIVE,
|
||||
PollenLevels.NONE}
|
||||
|
||||
|
||||
def test_pollen_default_values():
|
||||
assert PollenParser.get_default_data() == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE}
|
||||
assert PollenParser.get_default_data() == {PollenNames.BIRCH: PollenLevels.NONE,
|
||||
PollenNames.OAK: PollenLevels.NONE,
|
||||
PollenNames.HAZEL: PollenLevels.NONE,
|
||||
PollenNames.MUGWORT: PollenLevels.NONE,
|
||||
PollenNames.ALDER: PollenLevels.NONE,
|
||||
PollenNames.GRASSES: PollenLevels.NONE,
|
||||
PollenNames.ASH: PollenLevels.NONE}
|
||||
|
||||
|
||||
async def test_pollen_data_from_api() -> None:
|
||||
|
@ -69,12 +69,12 @@ async def test_pollen_data_from_api() -> None:
|
|||
api.get_svg = AsyncMock(return_value=load_fixture("pollen.svg"))
|
||||
|
||||
result = await api.get_pollen()
|
||||
expected = {IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE,
|
||||
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.PURPLE,
|
||||
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE}
|
||||
expected = {PollenNames.MUGWORT: PollenLevels.NONE,
|
||||
PollenNames.BIRCH: PollenLevels.NONE,
|
||||
PollenNames.ALDER: PollenLevels.NONE,
|
||||
PollenNames.ASH: PollenLevels.NONE,
|
||||
PollenNames.OAK: PollenLevels.NONE,
|
||||
PollenNames.GRASSES: PollenLevels.PURPLE,
|
||||
PollenNames.HAZEL: PollenLevels.NONE}
|
||||
assert result == expected
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from unittest.mock import MagicMock, AsyncMock
|
|||
from zoneinfo import ZoneInfo
|
||||
|
||||
from irm_kmi_api.api import IrmKmiApiClientHa
|
||||
from irm_kmi_api.data import AnimationFrameData, RadarAnimationData, IrmKmiRadarStyle
|
||||
from irm_kmi_api.data import AnimationFrameData, RadarAnimationData, RadarStyle
|
||||
from irm_kmi_api.rain_graph import RainGraph
|
||||
from tests.conftest import load_fixture
|
||||
|
||||
|
@ -44,7 +44,7 @@ async def test_svg_frame_setup():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
await rain_graph._draw_svg_frame()
|
||||
|
@ -64,7 +64,7 @@ def test_svg_hint():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._write_hint()
|
||||
|
@ -80,7 +80,7 @@ def test_svg_time_bars():
|
|||
tz = datetime.UTC,
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._draw_hour_bars()
|
||||
|
@ -99,7 +99,7 @@ def test_draw_chances_path():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._draw_chances_path()
|
||||
|
@ -117,7 +117,7 @@ def test_draw_data_line():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._draw_data_line()
|
||||
|
@ -135,7 +135,7 @@ async def test_insert_background():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
await rain_graph._insert_background()
|
||||
|
@ -158,7 +158,7 @@ def test_draw_current_frame_line_moving():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._draw_current_fame_line()
|
||||
|
@ -186,7 +186,7 @@ def test_draw_current_frame_line_index():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._draw_current_fame_line(0)
|
||||
|
@ -215,7 +215,7 @@ def test_draw_description_text():
|
|||
tz=datetime.UTC,
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._draw_description_text()
|
||||
|
@ -242,7 +242,7 @@ def test_draw_cloud_layer():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._insert_cloud_layer()
|
||||
|
@ -262,7 +262,7 @@ async def test_draw_location_layer():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
await rain_graph._draw_location()
|
||||
|
@ -280,7 +280,7 @@ def test_get_animation_data():
|
|||
|
||||
tz = ZoneInfo('Europe/Brussels')
|
||||
lang = 'en'
|
||||
style = IrmKmiRadarStyle.OPTION_STYLE_SATELLITE
|
||||
style = RadarStyle.OPTION_STYLE_SATELLITE
|
||||
dark_mode = False
|
||||
|
||||
api._api_data = json.loads(load_fixture("forecast.json"))
|
||||
|
@ -305,7 +305,7 @@ async def test_download_single_cloud():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._api_client = MagicMock()
|
||||
|
@ -323,7 +323,7 @@ async def test_download_many_clouds():
|
|||
rain_graph = RainGraph(
|
||||
animation_data=data,
|
||||
country='BE',
|
||||
style=IrmKmiRadarStyle.OPTION_STYLE_STD,
|
||||
style=RadarStyle.OPTION_STYLE_STD,
|
||||
)
|
||||
|
||||
rain_graph._api_client = MagicMock()
|
||||
|
@ -338,11 +338,11 @@ def test_can_build_rain_graph_with_empty_sequence():
|
|||
|
||||
RainGraph(
|
||||
RadarAnimationData(sequence=None),
|
||||
'BE', IrmKmiRadarStyle.OPTION_STYLE_STD
|
||||
'BE', RadarStyle.OPTION_STYLE_STD
|
||||
)
|
||||
|
||||
RainGraph(
|
||||
RadarAnimationData(sequence=[]),
|
||||
'BE', IrmKmiRadarStyle.OPTION_STYLE_STD
|
||||
'BE', RadarStyle.OPTION_STYLE_STD
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue