From 8253a27c4ca419415ada9fe3ea772ec90b97497e Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 2 Feb 2025 14:20:48 -0500 Subject: [PATCH] Slight Fix I belive there is a larger refactor in place, because it seems there is a lot of repetiveness within the code in weather.py All test have passed for now but will come back later to this issue. --- tests/weather_test.py | 4 ++-- weather.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/weather_test.py b/tests/weather_test.py index c9fca99..7b2304e 100644 --- a/tests/weather_test.py +++ b/tests/weather_test.py @@ -42,9 +42,9 @@ def test_successful_api_call(self, mock_get): result = fetch_weather_forecast() self.assertIsNotNone(result) - self.assertEqual(len(result), 2) + self.assertEqual(len(result), 1) self.assertEqual(result["day_1"][0]["name"], "Monday") - self.assertEqual(result["day_2"][0]["name"], "Tuesday") + self.assertEqual(result["day_1"][1]["name"], "Monday Night") @patch("requests.get") def test_api_connection_error(self, mock_get): diff --git a/weather.py b/weather.py index e0703ee..7d2ff7a 100644 --- a/weather.py +++ b/weather.py @@ -23,7 +23,7 @@ def fetch_weather_forecast(): forecast_days = [] - for i in range(4): + for i in range(2): period = forecast[i] forecast_days.append({ "name": period.get("name"), @@ -35,10 +35,8 @@ def fetch_weather_forecast(): "detailedForecast": period.get("detailedForecast") }) - # Group forecast into two-day structure consolidated_forecast = { - "day_1": forecast_days[:2], - "day_2": forecast_days[2:4], + "day_1": forecast_days[:2] } return consolidated_forecast