diff --git a/setup.py b/setup.py index 56411fc..0b64033 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="simple_dwd_weatherforecast", - version="1.1.0", + version="1.1.1", author="Max Fermor", description="A simple tool to retrieve a weather forecast from DWD OpenData", long_description=long_description, diff --git a/simple_dwd_weatherforecast/dwdforecast.py b/simple_dwd_weatherforecast/dwdforecast.py index b86cfe5..0200632 100644 --- a/simple_dwd_weatherforecast/dwdforecast.py +++ b/simple_dwd_weatherforecast/dwdforecast.py @@ -206,6 +206,11 @@ def get_condition(self, weather_data): if len(weather_data) == 0: return None + if len(weather_data) == 1: + return self.weather_codes[weather_data[0][WeatherDataType.CONDITION.value]][ + 0 + ] + priority = 99 condition_text = "" sunny_counter = 1 diff --git a/tests/test_get_timeframe_condition.py b/tests/test_get_timeframe_condition.py index d3e25a8..8f5794d 100644 --- a/tests/test_get_timeframe_condition.py +++ b/tests/test_get_timeframe_condition.py @@ -1,6 +1,6 @@ import unittest from unittest.mock import patch -from datetime import datetime +from datetime import datetime, timedelta from simple_dwd_weatherforecast import dwdforecast from tests.dummy_data import parsed_data @@ -58,3 +58,26 @@ def test_3_max(self, _): self.dwd_weather.get_timeframe_condition(test_time, 3), "cloudy", ) + + @patch("simple_dwd_weatherforecast.dwdforecast.Weather.update", return_value=None) + def test_hourly_timeframe(self, _): + test_time = datetime(2020, 11, 6, 4, 0) + self.assertEqual( + self.dwd_weather.get_timeframe_condition(test_time, 1), + "partlycloudy", + ) + test_time = test_time + timedelta(hours=1) + self.assertEqual( + self.dwd_weather.get_timeframe_condition(test_time, 1), + "cloudy", + ) + test_time = test_time + timedelta(hours=1) + self.assertEqual( + self.dwd_weather.get_timeframe_condition(test_time, 1), + "sunny", + ) + test_time = test_time + timedelta(hours=1) + self.assertEqual( + self.dwd_weather.get_timeframe_condition(test_time, 1), + "fog", + )