Breaking: remove prefix from data types

This commit is contained in:
Jules 2025-05-05 21:44:50 +02:00
parent 9641b4219b
commit c06f1c8972
Signed by: jdejaegh
GPG key ID: 99D6D184CA66933A
8 changed files with 107 additions and 107 deletions

View file

@ -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 MAP_WARNING_ID_TO_SLUG as SLUG_MAP, WWEVOL_TO_ENUM_MAP
from .const import STYLE_TO_PARAM_MAP, WEEKDAYS from .const import STYLE_TO_PARAM_MAP, WEEKDAYS
from .data import (AnimationFrameData, CurrentWeatherData, Forecast, from .data import (AnimationFrameData, CurrentWeatherData, Forecast,
IrmKmiForecast, IrmKmiRadarForecast, RadarAnimationData, ExtendedForecast, IrmKmiRadarForecast, RadarAnimationData,
WarningData, IrmKmiRadarStyle) WarningData, RadarStyle)
from .pollen import PollenParser from .pollen import PollenParser
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -344,7 +344,7 @@ class IrmKmiApiClientHa(IrmKmiApiClient):
return forecasts 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. Parse the API data we currently have to build the daily forecast list.
@ -416,7 +416,7 @@ class IrmKmiApiClientHa(IrmKmiApiClient):
except (TypeError, ValueError): except (TypeError, ValueError):
pass pass
forecast = IrmKmiForecast( forecast = ExtendedForecast(
datetime=(forecast_day.strftime('%Y-%m-%d')), datetime=(forecast_day.strftime('%Y-%m-%d')),
condition=self._cdt_map.get((f.get('ww1', None), f.get('dayNight', None)), None), 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), condition_2=self._cdt_map.get((f.get('ww2', None), f.get('dayNight', None)), None),
@ -444,7 +444,7 @@ class IrmKmiApiClientHa(IrmKmiApiClient):
return forecasts 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. Get all the image URLs and create the radar animation data object.

View file

@ -1,23 +1,23 @@
from typing import Final from typing import Final
from .data import IrmKmiConditionEvol, IrmKmiRadarStyle, IrmKmiPollenLevels from .data import ConditionEvol, RadarStyle, PollenLevels
POLLEN_LEVEL_TO_COLOR = { POLLEN_LEVEL_TO_COLOR = {
'null': IrmKmiPollenLevels.GREEN, 'null': PollenLevels.GREEN,
'low': IrmKmiPollenLevels.YELLOW, 'low': PollenLevels.YELLOW,
'moderate': IrmKmiPollenLevels.ORANGE, 'moderate': PollenLevels.ORANGE,
'high': IrmKmiPollenLevels.RED, 'high': PollenLevels.RED,
'very high': IrmKmiPollenLevels.PURPLE, 'very high': PollenLevels.PURPLE,
'active': IrmKmiPollenLevels.ACTIVE 'active': PollenLevels.ACTIVE
} }
WEEKDAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] WEEKDAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
STYLE_TO_PARAM_MAP: Final = { STYLE_TO_PARAM_MAP: Final = {
IrmKmiRadarStyle.OPTION_STYLE_STD: 1, RadarStyle.OPTION_STYLE_STD: 1,
IrmKmiRadarStyle.OPTION_STYLE_CONTRAST: 2, RadarStyle.OPTION_STYLE_CONTRAST: 2,
IrmKmiRadarStyle.OPTION_STYLE_YELLOW_RED: 3, RadarStyle.OPTION_STYLE_YELLOW_RED: 3,
IrmKmiRadarStyle.OPTION_STYLE_SATELLITE: 4 RadarStyle.OPTION_STYLE_SATELLITE: 4
} }
MAP_WARNING_ID_TO_SLUG: Final = { MAP_WARNING_ID_TO_SLUG: Final = {
@ -34,7 +34,7 @@ MAP_WARNING_ID_TO_SLUG: Final = {
17: 'coldspell'} 17: 'coldspell'}
WWEVOL_TO_ENUM_MAP: Final = { WWEVOL_TO_ENUM_MAP: Final = {
None: IrmKmiConditionEvol.STABLE, None: ConditionEvol.STABLE,
0: IrmKmiConditionEvol.ONE_WAY, 0: ConditionEvol.ONE_WAY,
1: IrmKmiConditionEvol.TWO_WAYS 1: ConditionEvol.TWO_WAYS
} }

View file

@ -36,7 +36,7 @@ class Forecast(TypedDict, total=False):
is_daytime: bool | None # Mandatory to use with forecast_twice_daily is_daytime: bool | None # Mandatory to use with forecast_twice_daily
class IrmKmiConditionEvol(Enum): class ConditionEvol(Enum):
"""Possible state for evolution between weather conditions""" """Possible state for evolution between weather conditions"""
ONE_WAY = 'one_way' ONE_WAY = 'one_way'
@ -44,7 +44,7 @@ class IrmKmiConditionEvol(Enum):
STABLE = 'stable' STABLE = 'stable'
class IrmKmiRadarStyle(Enum): class RadarStyle(Enum):
"""Possible style for the rain radar""" """Possible style for the rain radar"""
OPTION_STYLE_STD = 'standard_style' OPTION_STYLE_STD = 'standard_style'
@ -53,7 +53,7 @@ class IrmKmiRadarStyle(Enum):
OPTION_STYLE_SATELLITE = 'satellite_style' OPTION_STYLE_SATELLITE = 'satellite_style'
class IrmKmiPollenNames(Enum): class PollenNames(Enum):
"""Pollens names from the API""" """Pollens names from the API"""
ALDER = 'alder' ALDER = 'alder'
@ -65,7 +65,7 @@ class IrmKmiPollenNames(Enum):
OAK = 'oak' OAK = 'oak'
class IrmKmiPollenLevels(Enum): class PollenLevels(Enum):
"""Possible pollen levels""" """Possible pollen levels"""
NONE = 'none' NONE = 'none'
@ -77,11 +77,11 @@ class IrmKmiPollenLevels(Enum):
PURPLE = 'purple' PURPLE = 'purple'
class IrmKmiForecast(Forecast, total=False): class ExtendedForecast(Forecast, total=False):
"""Forecast class with additional attributes for IRM KMI""" """Forecast class with additional attributes for IRM KMI"""
condition_2: str | None condition_2: str | None
condition_evol: IrmKmiConditionEvol | None condition_evol: ConditionEvol | None
text: str | None text: str | None
sunrise: str | None sunrise: str | None
sunset: str | None sunset: str | None

View file

@ -4,7 +4,7 @@ import xml.etree.ElementTree as ET
from typing import List, Dict from typing import List, Dict
from .const import POLLEN_LEVEL_TO_COLOR from .const import POLLEN_LEVEL_TO_COLOR
from .data import IrmKmiPollenNames, IrmKmiPollenLevels from .data import PollenNames, PollenLevels
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -22,7 +22,7 @@ class PollenParser:
): ):
self._xml = xml_string 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. Parse the SVG and extract the pollen data from the image.
If an error occurs, return the default value. If an error occurs, return the default value.
@ -40,7 +40,7 @@ class PollenParser:
elements: List[ET.Element] = self._extract_elements(root) elements: List[ET.Element] = self._extract_elements(root)
pollens = {e.attrib.get('x', None): self._get_txt(e).lower() 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)] 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} 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(): for position, pollen in pollens.items():
# Check if pollen is a known one # Check if pollen is a known one
try: try:
pollen: IrmKmiPollenNames = IrmKmiPollenNames(pollen) pollen: PollenNames = PollenNames(pollen)
except ValueError: except ValueError:
_LOGGER.warning(f'Unknown pollen name {pollen}') _LOGGER.warning(f'Unknown pollen name {pollen}')
continue continue
@ -62,7 +62,7 @@ class PollenParser:
pollen_data[pollen] = pollen_levels[position] pollen_data[pollen] = pollen_levels[position]
_LOGGER.debug(f"{pollen.value} is {pollen_data[pollen]} according to text") _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 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") _LOGGER.debug(f"{pollen} trusting text")
else: else:
for dot in level_dots: for dot in level_dots:
@ -72,15 +72,15 @@ class PollenParser:
pass pass
else: else:
if 24 <= relative_x_position <= 34: if 24 <= relative_x_position <= 34:
pollen_data[pollen] = IrmKmiPollenLevels.GREEN pollen_data[pollen] = PollenLevels.GREEN
elif 13 <= relative_x_position <= 23: elif 13 <= relative_x_position <= 23:
pollen_data[pollen] = IrmKmiPollenLevels.YELLOW pollen_data[pollen] = PollenLevels.YELLOW
elif -5 <= relative_x_position <= 5: elif -5 <= relative_x_position <= 5:
pollen_data[pollen] = IrmKmiPollenLevels.ORANGE pollen_data[pollen] = PollenLevels.ORANGE
elif -23 <= relative_x_position <= -13: elif -23 <= relative_x_position <= -13:
pollen_data[pollen] = IrmKmiPollenLevels.RED pollen_data[pollen] = PollenLevels.RED
elif -34 <= relative_x_position <= -24: 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") _LOGGER.debug(f"{pollen.value} is {pollen_data[pollen]} according to dot")
@ -88,19 +88,19 @@ class PollenParser:
return pollen_data return pollen_data
@staticmethod @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 all the known pollen with 'none' value"""
return {k: IrmKmiPollenLevels.NONE for k in IrmKmiPollenNames} return {k: PollenLevels.NONE for k in PollenNames}
@staticmethod @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 all the known pollen with None value"""
return {k: None for k in IrmKmiPollenNames} return {k: None for k in PollenNames}
@staticmethod @staticmethod
def get_option_values() -> List[IrmKmiPollenLevels]: def get_option_values() -> List[PollenLevels]:
"""List all the values that the pollen can have""" """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 @staticmethod
def _extract_elements(root) -> List[ET.Element]: def _extract_elements(root) -> List[ET.Element]:

View file

@ -12,7 +12,7 @@ from svgwrite.animate import Animate
from svgwrite.container import FONT_TEMPLATE from svgwrite.container import FONT_TEMPLATE
from .api import IrmKmiApiClient, IrmKmiApiError 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 from .resources import be_black, be_satellite, be_white, nl, roboto
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -24,7 +24,7 @@ class RainGraph:
def __init__(self, def __init__(self,
animation_data: RadarAnimationData, animation_data: RadarAnimationData,
country: str, country: str,
style: IrmKmiRadarStyle, style: RadarStyle,
dark_mode: bool = False, dark_mode: bool = False,
tz: datetime.tzinfo = None, tz: datetime.tzinfo = None,
svg_width: float = 640, svg_width: float = 640,
@ -431,7 +431,7 @@ class RainGraph:
def _get_background_png_b64(self) -> str: def _get_background_png_b64(self) -> str:
if self._country == 'NL': if self._country == 'NL':
return nl.nl_b64 return nl.nl_b64
elif self._style == IrmKmiRadarStyle.OPTION_STYLE_SATELLITE: elif self._style == RadarStyle.OPTION_STYLE_SATELLITE:
return be_satellite.be_satelitte_b64 return be_satellite.be_satelitte_b64
elif self._dark_mode: elif self._dark_mode:
return be_black.be_black_b64 return be_black.be_black_b64

View file

@ -3,7 +3,7 @@ from zoneinfo import ZoneInfo
from freezegun import freeze_time 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.conftest import get_api_with_data
from tests.const import ATTR_CONDITION_PARTLYCLOUDY from tests.const import ATTR_CONDITION_PARTLYCLOUDY
@ -19,11 +19,11 @@ async def test_daily_forecast() -> None:
assert len(result) == 8 assert len(result) == 8
assert result[0]['datetime'] == '2023-12-26' assert result[0]['datetime'] == '2023-12-26'
assert not result[0]['is_daytime'] assert not result[0]['is_daytime']
expected = IrmKmiForecast( expected = ExtendedForecast(
datetime='2023-12-27', datetime='2023-12-27',
condition=ATTR_CONDITION_PARTLYCLOUDY, condition=ATTR_CONDITION_PARTLYCLOUDY,
condition_2=None, condition_2=None,
condition_evol=IrmKmiConditionEvol.TWO_WAYS, condition_evol=ConditionEvol.TWO_WAYS,
native_precipitation=0, native_precipitation=0,
native_temperature=9, native_temperature=9,
native_templow=4, native_templow=4,

View file

@ -1,7 +1,7 @@
import logging import logging
from unittest.mock import AsyncMock 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 irm_kmi_api.pollen import PollenParser
from tests.conftest import get_api_with_data, load_fixture 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: with open("tests/fixtures/pollen.svg", "r") as file:
svg_data = file.read() svg_data = file.read()
data = PollenParser(svg_data).get_pollen_data() data = PollenParser(svg_data).get_pollen_data()
assert data == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE, assert data == {PollenNames.BIRCH: PollenLevels.NONE,
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE, PollenNames.OAK: PollenLevels.NONE,
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE, PollenNames.HAZEL: PollenLevels.NONE,
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE, PollenNames.MUGWORT: PollenLevels.NONE,
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE, PollenNames.ALDER: PollenLevels.NONE,
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.PURPLE, PollenNames.GRASSES: PollenLevels.PURPLE,
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE} PollenNames.ASH: PollenLevels.NONE}
def test_svg_two_pollen_parsing(): def test_svg_two_pollen_parsing():
with open("tests/fixtures/new_two_pollens.svg", "r") as file: with open("tests/fixtures/new_two_pollens.svg", "r") as file:
svg_data = file.read() svg_data = file.read()
data = PollenParser(svg_data).get_pollen_data() data = PollenParser(svg_data).get_pollen_data()
assert data == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE, assert data == {PollenNames.BIRCH: PollenLevels.NONE,
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE, PollenNames.OAK: PollenLevels.NONE,
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE, PollenNames.HAZEL: PollenLevels.NONE,
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.ACTIVE, PollenNames.MUGWORT: PollenLevels.ACTIVE,
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE, PollenNames.ALDER: PollenLevels.NONE,
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.RED, PollenNames.GRASSES: PollenLevels.RED,
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE} PollenNames.ASH: PollenLevels.NONE}
def test_svg_two_pollen_parsing_2025_update(): def test_svg_two_pollen_parsing_2025_update():
with open("tests/fixtures/pollens-2025.svg", "r") as file: with open("tests/fixtures/pollens-2025.svg", "r") as file:
svg_data = file.read() svg_data = file.read()
data = PollenParser(svg_data).get_pollen_data() data = PollenParser(svg_data).get_pollen_data()
assert data == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE, assert data == {PollenNames.BIRCH: PollenLevels.NONE,
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE, PollenNames.OAK: PollenLevels.NONE,
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.ACTIVE, PollenNames.HAZEL: PollenLevels.ACTIVE,
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE, PollenNames.MUGWORT: PollenLevels.NONE,
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.GREEN, PollenNames.ALDER: PollenLevels.GREEN,
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.NONE, PollenNames.GRASSES: PollenLevels.NONE,
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE} PollenNames.ASH: PollenLevels.NONE}
def test_pollen_options(): def test_pollen_options():
assert set(PollenParser.get_option_values()) == {IrmKmiPollenLevels.GREEN, assert set(PollenParser.get_option_values()) == {PollenLevels.GREEN,
IrmKmiPollenLevels.YELLOW, PollenLevels.YELLOW,
IrmKmiPollenLevels.ORANGE, PollenLevels.ORANGE,
IrmKmiPollenLevels.RED, PollenLevels.RED,
IrmKmiPollenLevels.PURPLE, PollenLevels.PURPLE,
IrmKmiPollenLevels.ACTIVE, PollenLevels.ACTIVE,
IrmKmiPollenLevels.NONE} PollenLevels.NONE}
def test_pollen_default_values(): def test_pollen_default_values():
assert PollenParser.get_default_data() == {IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE, assert PollenParser.get_default_data() == {PollenNames.BIRCH: PollenLevels.NONE,
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE, PollenNames.OAK: PollenLevels.NONE,
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE, PollenNames.HAZEL: PollenLevels.NONE,
IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE, PollenNames.MUGWORT: PollenLevels.NONE,
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE, PollenNames.ALDER: PollenLevels.NONE,
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.NONE, PollenNames.GRASSES: PollenLevels.NONE,
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE} PollenNames.ASH: PollenLevels.NONE}
async def test_pollen_data_from_api() -> 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")) api.get_svg = AsyncMock(return_value=load_fixture("pollen.svg"))
result = await api.get_pollen() result = await api.get_pollen()
expected = {IrmKmiPollenNames.MUGWORT: IrmKmiPollenLevels.NONE, expected = {PollenNames.MUGWORT: PollenLevels.NONE,
IrmKmiPollenNames.BIRCH: IrmKmiPollenLevels.NONE, PollenNames.BIRCH: PollenLevels.NONE,
IrmKmiPollenNames.ALDER: IrmKmiPollenLevels.NONE, PollenNames.ALDER: PollenLevels.NONE,
IrmKmiPollenNames.ASH: IrmKmiPollenLevels.NONE, PollenNames.ASH: PollenLevels.NONE,
IrmKmiPollenNames.OAK: IrmKmiPollenLevels.NONE, PollenNames.OAK: PollenLevels.NONE,
IrmKmiPollenNames.GRASSES: IrmKmiPollenLevels.PURPLE, PollenNames.GRASSES: PollenLevels.PURPLE,
IrmKmiPollenNames.HAZEL: IrmKmiPollenLevels.NONE} PollenNames.HAZEL: PollenLevels.NONE}
assert result == expected assert result == expected

View file

@ -7,7 +7,7 @@ from unittest.mock import MagicMock, AsyncMock
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
from irm_kmi_api.api import IrmKmiApiClientHa 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 irm_kmi_api.rain_graph import RainGraph
from tests.conftest import load_fixture from tests.conftest import load_fixture
@ -44,7 +44,7 @@ async def test_svg_frame_setup():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
await rain_graph._draw_svg_frame() await rain_graph._draw_svg_frame()
@ -64,7 +64,7 @@ def test_svg_hint():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._write_hint() rain_graph._write_hint()
@ -80,7 +80,7 @@ def test_svg_time_bars():
tz = datetime.UTC, tz = datetime.UTC,
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._draw_hour_bars() rain_graph._draw_hour_bars()
@ -99,7 +99,7 @@ def test_draw_chances_path():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._draw_chances_path() rain_graph._draw_chances_path()
@ -117,7 +117,7 @@ def test_draw_data_line():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._draw_data_line() rain_graph._draw_data_line()
@ -135,7 +135,7 @@ async def test_insert_background():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
await rain_graph._insert_background() await rain_graph._insert_background()
@ -158,7 +158,7 @@ def test_draw_current_frame_line_moving():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._draw_current_fame_line() rain_graph._draw_current_fame_line()
@ -186,7 +186,7 @@ def test_draw_current_frame_line_index():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._draw_current_fame_line(0) rain_graph._draw_current_fame_line(0)
@ -215,7 +215,7 @@ def test_draw_description_text():
tz=datetime.UTC, tz=datetime.UTC,
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._draw_description_text() rain_graph._draw_description_text()
@ -242,7 +242,7 @@ def test_draw_cloud_layer():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._insert_cloud_layer() rain_graph._insert_cloud_layer()
@ -262,7 +262,7 @@ async def test_draw_location_layer():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
await rain_graph._draw_location() await rain_graph._draw_location()
@ -280,7 +280,7 @@ def test_get_animation_data():
tz = ZoneInfo('Europe/Brussels') tz = ZoneInfo('Europe/Brussels')
lang = 'en' lang = 'en'
style = IrmKmiRadarStyle.OPTION_STYLE_SATELLITE style = RadarStyle.OPTION_STYLE_SATELLITE
dark_mode = False dark_mode = False
api._api_data = json.loads(load_fixture("forecast.json")) api._api_data = json.loads(load_fixture("forecast.json"))
@ -305,7 +305,7 @@ async def test_download_single_cloud():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._api_client = MagicMock() rain_graph._api_client = MagicMock()
@ -323,7 +323,7 @@ async def test_download_many_clouds():
rain_graph = RainGraph( rain_graph = RainGraph(
animation_data=data, animation_data=data,
country='BE', country='BE',
style=IrmKmiRadarStyle.OPTION_STYLE_STD, style=RadarStyle.OPTION_STYLE_STD,
) )
rain_graph._api_client = MagicMock() rain_graph._api_client = MagicMock()
@ -338,11 +338,11 @@ def test_can_build_rain_graph_with_empty_sequence():
RainGraph( RainGraph(
RadarAnimationData(sequence=None), RadarAnimationData(sequence=None),
'BE', IrmKmiRadarStyle.OPTION_STYLE_STD 'BE', RadarStyle.OPTION_STYLE_STD
) )
RainGraph( RainGraph(
RadarAnimationData(sequence=[]), RadarAnimationData(sequence=[]),
'BE', IrmKmiRadarStyle.OPTION_STYLE_STD 'BE', RadarStyle.OPTION_STYLE_STD
) )