Restructure translations for entity components (#89702)

This commit is contained in:
Franck Nijhof 2023-03-16 12:16:08 +01:00 committed by GitHub
parent f55aaf7664
commit f32b7859b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 435 additions and 321 deletions

View file

@ -373,32 +373,32 @@ async def test_caching(hass: HomeAssistant) -> None:
"homeassistant.helpers.translation._merge_resources",
side_effect=translation._merge_resources,
) as mock_merge:
load1 = await translation.async_get_translations(hass, "en", "state")
load1 = await translation.async_get_translations(hass, "en", "entity_component")
assert len(mock_merge.mock_calls) == 1
load2 = await translation.async_get_translations(hass, "en", "state")
load2 = await translation.async_get_translations(hass, "en", "entity_component")
assert len(mock_merge.mock_calls) == 1
assert load1 == load2
for key in load1:
assert key.startswith("component.sensor.state.") or key.startswith(
"component.light.state."
)
assert key.startswith(
"component.sensor.entity_component._.state."
) or key.startswith("component.light.entity_component._.state.")
load_sensor_only = await translation.async_get_translations(
hass, "en", "state", integrations={"sensor"}
hass, "en", "entity_component", integrations={"sensor"}
)
assert load_sensor_only
for key in load_sensor_only:
assert key.startswith("component.sensor.state.")
assert key.startswith("component.sensor.entity_component._.state.")
load_light_only = await translation.async_get_translations(
hass, "en", "state", integrations={"light"}
hass, "en", "entity_component", integrations={"light"}
)
assert load_light_only
for key in load_light_only:
assert key.startswith("component.light.state.")
assert key.startswith("component.light.entity_component._.state.")
hass.config.components.add("media_player")