Add test and fix minor issue

This commit is contained in:
Jules 2025-05-03 17:36:59 +02:00
parent 67f1740474
commit dfb9ccb5ef
Signed by: jdejaegh
GPG key ID: 99D6D184CA66933A
4 changed files with 16 additions and 4 deletions

View file

@ -56,7 +56,8 @@ class RainGraph:
self._bottom_text_y_pos: float = bottom_text_y_pos + self._background_size[1]
self._api_client = api_client
self._frame_count: int = len(self._animation_data['sequence'])
self._sequence = self._animation_data['sequence'] if self._animation_data['sequence'] is not None else []
self._frame_count: int = max(len(self._sequence), 1)
self._graph_width: float = self._svg_width - 2 * self._inset
self._graph_bottom: float = self._top_text_space + self._graph_height
self._svg_height: float = self._graph_height + self._top_text_space + self._bottom_text_space

View file

@ -1,2 +1 @@
"""Tests for the IRM KMI custom integration."""
# Test suite inspired by https://github.com/home-assistant/core/tree/dev/tests/components/open_meteo
"""Tests for the IRM KMI api package."""

View file

@ -1,4 +1,4 @@
"""Fixtures for the IRM KMI integration tests."""
"""Fixtures for the IRM KMI api package."""
from __future__ import annotations
import json

View file

@ -335,3 +335,15 @@ async def test_download_many_clouds():
for i in range(10):
rain_graph._api_client.get_image.assert_any_call(f'image-url-{i}')
def test_can_build_rain_graph_with_empty_sequence():
# RainGraph(
# RadarAnimationData(sequence=None),
# 'en', 'style'
# )
RainGraph(
RadarAnimationData(sequence=[]),
'en', 'style'
)