From b1933c07c351019a45ea337ee12173041eb4f8f7 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 21 May 2026 15:53:39 +0000 Subject: [PATCH] =?UTF-8?q?GoogleSolarApiClient=20propagates=20exception?= =?UTF-8?q?=20after=20retry=20exhaustion=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solar/test_google_solar_api_client.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/infrastructure/solar/test_google_solar_api_client.py b/tests/infrastructure/solar/test_google_solar_api_client.py index 450113a7..d4328fc0 100644 --- a/tests/infrastructure/solar/test_google_solar_api_client.py +++ b/tests/infrastructure/solar/test_google_solar_api_client.py @@ -87,3 +87,24 @@ def test_get_building_insights_raises_on_entity_not_found() -> None: client.get_building_insights(longitude=-0.1278, latitude=51.5074) assert mock_get.call_count == 1 + + +# --------------------------------------------------------------------------- +# Slice 4: Retry exhaustion propagates the exception to the caller +# --------------------------------------------------------------------------- + + +def test_get_building_insights_propagates_exception_after_retry_exhaustion() -> None: + # Arrange + client = GoogleSolarApiClient(api_key="test-key") + + error = requests.exceptions.ConnectionError("persistent failure") + error.response = None # type: ignore[attr-defined] + + with patch("requests.get", side_effect=error) as mock_get: + with patch("time.sleep"): + # Act / Assert + with pytest.raises(requests.exceptions.ConnectionError): + client.get_building_insights(longitude=-0.1278, latitude=51.5074) + + assert mock_get.call_count == GoogleSolarApiClient.MAX_RETRIES