1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Support requesting translations for multiple integrations in a single request (#71979)

This commit is contained in:
J. Nick Koston
2022-05-17 01:23:11 -05:00
committed by GitHub
parent 78f0716574
commit a614ddca28
5 changed files with 88 additions and 15 deletions

View File

@@ -424,7 +424,7 @@ async def test_get_translations(hass, ws_client):
"""Test get_translations command."""
with patch(
"homeassistant.components.frontend.async_get_translations",
side_effect=lambda hass, lang, category, integration, config_flow: {
side_effect=lambda hass, lang, category, integrations, config_flow: {
"lang": lang
},
):
@@ -444,6 +444,58 @@ async def test_get_translations(hass, ws_client):
assert msg["result"] == {"resources": {"lang": "nl"}}
async def test_get_translations_for_integrations(hass, ws_client):
"""Test get_translations for integrations command."""
with patch(
"homeassistant.components.frontend.async_get_translations",
side_effect=lambda hass, lang, category, integration, config_flow: {
"lang": lang,
"integration": integration,
},
):
await ws_client.send_json(
{
"id": 5,
"type": "frontend/get_translations",
"integration": ["frontend", "http"],
"language": "nl",
"category": "lang",
}
)
msg = await ws_client.receive_json()
assert msg["id"] == 5
assert msg["type"] == TYPE_RESULT
assert msg["success"]
assert set(msg["result"]["resources"]["integration"]) == {"frontend", "http"}
async def test_get_translations_for_single_integration(hass, ws_client):
"""Test get_translations for integration command."""
with patch(
"homeassistant.components.frontend.async_get_translations",
side_effect=lambda hass, lang, category, integrations, config_flow: {
"lang": lang,
"integration": integrations,
},
):
await ws_client.send_json(
{
"id": 5,
"type": "frontend/get_translations",
"integration": "http",
"language": "nl",
"category": "lang",
}
)
msg = await ws_client.receive_json()
assert msg["id"] == 5
assert msg["type"] == TYPE_RESULT
assert msg["success"]
assert msg["result"] == {"resources": {"lang": "nl", "integration": ["http"]}}
async def test_auth_load(hass):
"""Test auth component loaded by default."""
frontend = await async_get_integration(hass, "frontend")