diff --git a/setup.py b/setup.py index 9769209..be693d6 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="simple_dwd_weatherforecast", - version="2.0.33", + version="2.0.34", 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 90162f8..5b1a52d 100644 --- a/simple_dwd_weatherforecast/dwdforecast.py +++ b/simple_dwd_weatherforecast/dwdforecast.py @@ -298,13 +298,15 @@ def is_in_timerange_day(self, timestamp: datetime): return ( self.strip_to_day( arrow.get( - list(self.forecast_data.keys())[0], "YYYY-MM-DDTHH:mm:ss.SSSZ" # type: ignore + list(self.forecast_data.keys())[0], # type: ignore + "YYYY-MM-DDTHH:mm:ss.SSSZ", # type: ignore ).datetime ) <= self.strip_to_day(timestamp) <= self.strip_to_day( arrow.get( - list(self.forecast_data.keys())[-1], "YYYY-MM-DDTHH:mm:ss.SSSZ" # type: ignore + list(self.forecast_data.keys())[-1], # type: ignore + "YYYY-MM-DDTHH:mm:ss.SSSZ", # type: ignore ).datetime ) ) @@ -356,9 +358,11 @@ def get_timeframe_condition( return None def get_daily_condition(self, timestamp: datetime, shouldUpdate=True): + print("testieng") if shouldUpdate: self.update() - if self.is_in_timerange(timestamp): + if self.is_in_timerange_day(timestamp): + print("working") return self.get_condition(self.get_day_values(timestamp)) return None @@ -609,7 +613,8 @@ def get_day_values(self, timestamp: datetime): "timestamp has to be checked prior to be in timerange" result = [] first_entry_date = arrow.get( - next(iter(self.forecast_data)), "YYYY-MM-DDTHH:mm:ss.SSSZ" # type: ignore + next(iter(self.forecast_data)), # type: ignore + "YYYY-MM-DDTHH:mm:ss.SSSZ", # type: ignore ).datetime # type: ignore if timestamp.day != first_entry_date.day: time_step = self.strip_to_day(timestamp) diff --git a/tests/test_get_daily_condition.py b/tests/test_get_daily_condition.py index abc3876..7f991cd 100644 --- a/tests/test_get_daily_condition.py +++ b/tests/test_get_daily_condition.py @@ -49,3 +49,11 @@ def test_3_max(self, _): self.dwd_weather.get_daily_condition(test_time), "cloudy", ) + + @patch("simple_dwd_weatherforecast.dwdforecast.Weather.update", return_value=None) + def test_same_day(self, _): + test_time = datetime(2020, 11, 6, 0, 0) + self.assertEqual( + self.dwd_weather.get_daily_condition(test_time), + "sunny", + )