GoogleSolarApiClient propagates exception after retry exhaustion 🟩

This commit is contained in:
Daniel Roth 2026-05-21 15:53:39 +00:00
parent d1ca9be580
commit b1933c07c3

View file

@ -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