1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 08:26:41 +01:00

Add exception translations to Google Weather (#165935)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
tronikos
2026-03-18 13:25:58 -07:00
committed by GitHub
parent 877bca28ad
commit fa8e976de7
4 changed files with 19 additions and 3 deletions

View File

@@ -24,6 +24,8 @@ from homeassistant.helpers.update_coordinator import (
UpdateFailed,
)
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
T = TypeVar(
@@ -97,7 +99,13 @@ class GoogleWeatherBaseCoordinator(TimestampDataUpdateCoordinator[T]):
self.subentry.title,
err,
)
raise UpdateFailed(f"Error fetching {self._data_type_name}") from err
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="update_error",
translation_placeholders={
"error": str(err),
},
) from err
class GoogleWeatherCurrentConditionsCoordinator(

View File

@@ -66,7 +66,7 @@ rules:
entity-device-class: done
entity-disabled-by-default: done
entity-translations: done
exception-translations: todo
exception-translations: done
icon-translations: done
reconfiguration-flow: todo
repair-issues:

View File

@@ -98,5 +98,10 @@
"name": "Wind gust speed"
}
}
},
"exceptions": {
"update_error": {
"message": "Error fetching weather data: {error}"
}
}
}

View File

@@ -42,16 +42,19 @@ async def test_config_not_ready(
mock_config_entry: MockConfigEntry,
mock_google_weather_api: AsyncMock,
failing_api_method: str,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test for setup failure if an API call fails."""
getattr(
mock_google_weather_api, failing_api_method
).side_effect = GoogleWeatherApiError()
).side_effect = GoogleWeatherApiError("API error")
await hass.config_entries.async_setup(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
assert "Error fetching weather data: API error" in caplog.text
async def test_unload_entry(
hass: HomeAssistant,