mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
GoogleSolarApiClient raises BuildingInsightsNotFoundError on 404 entity-not-found 🟥
This commit is contained in:
parent
497ef1faed
commit
573656be64
1 changed files with 29 additions and 0 deletions
|
|
@ -58,3 +58,32 @@ def test_get_building_insights_retries_on_transient_error() -> None:
|
|||
# Assert
|
||||
assert result == payload
|
||||
assert mock_get.call_count == 2
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Slice 3: 404 + entity-not-found raises BuildingInsightsNotFoundError
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_get_building_insights_raises_on_entity_not_found() -> None:
|
||||
# Arrange
|
||||
client = GoogleSolarApiClient(api_key="test-key")
|
||||
|
||||
not_found_response = MagicMock()
|
||||
not_found_response.status_code = 404
|
||||
not_found_response.json.return_value = {
|
||||
"error": {"message": GoogleSolarApiClient.ENTITY_NOT_FOUND_ERROR}
|
||||
}
|
||||
|
||||
http_error = requests.exceptions.HTTPError("404")
|
||||
http_error.response = not_found_response
|
||||
|
||||
with patch("requests.get") as mock_get:
|
||||
mock_get.return_value.raise_for_status.side_effect = http_error
|
||||
mock_get.return_value.response = not_found_response
|
||||
|
||||
# Act / Assert
|
||||
with pytest.raises(BuildingInsightsNotFoundError):
|
||||
client.get_building_insights(longitude=-0.1278, latitude=51.5074)
|
||||
|
||||
assert mock_get.call_count == 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue