diff --git a/irm_kmi_api/rain_graph.py b/irm_kmi_api/rain_graph.py index 7d509ba..411ba04 100644 --- a/irm_kmi_api/rain_graph.py +++ b/irm_kmi_api/rain_graph.py @@ -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 diff --git a/tests/__init__.py b/tests/__init__.py index 697e689..b7f4622 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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.""" diff --git a/tests/conftest.py b/tests/conftest.py index 9d58fb6..e207cb0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,4 @@ -"""Fixtures for the IRM KMI integration tests.""" +"""Fixtures for the IRM KMI api package.""" from __future__ import annotations import json diff --git a/tests/test_rain_graph.py b/tests/test_rain_graph.py index 626faa7..e5d4c03 100644 --- a/tests/test_rain_graph.py +++ b/tests/test_rain_graph.py @@ -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' + ) +