1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Fix incorrect scope on checking files to load in translations (#112457)

discovered in https://github.com/home-assistant/core/pull/112295#discussion_r1513505710

We only checked if the last language had files to load
instead of all of them. The checks for each language
are the same because the only reason we would skip
a language is a missing/broken integration or the integration
is a single file. Both of these loop conditions are always
the same reguardless of the language so the check worked
This commit is contained in:
J. Nick Koston
2024-03-05 18:46:24 -10:00
committed by GitHub
parent f5700aa318
commit 982c8f8f4a
2 changed files with 38 additions and 5 deletions

View File

@@ -541,6 +541,37 @@ async def test_ensure_translations_still_load_if_one_integration_fails(
assert translations == sensor_translations
async def test_load_translations_all_integrations_broken(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
"""Ensure we do not try to load translations again if the integration is broken."""
hass.config.components.add("broken")
hass.config.components.add("broken2")
with patch(
"homeassistant.helpers.translation.async_get_integrations",
return_value={
"broken2": Exception("unhandled failure"),
"broken": Exception("unhandled failure"),
},
):
translations = await translation.async_get_translations(
hass, "en", "entity_component", integrations={"broken", "broken2"}
)
assert "Failed to load integration for translation" in caplog.text
assert "broken" in caplog.text
assert "broken2" in caplog.text
assert not translations
caplog.clear()
translations = await translation.async_get_translations(
hass, "en", "entity_component", integrations={"broken", "broken2"}
)
assert not translations
# Ensure we do not try again
assert "Failed to load integration for translation" not in caplog.text
async def test_caching(hass: HomeAssistant) -> None:
"""Test we cache data."""
hass.config.components.add("sensor")