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

Add icon translations support (#103294)

Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
This commit is contained in:
Franck Nijhof
2024-01-19 16:56:56 +01:00
committed by GitHub
parent ed449a5abd
commit 01372024f5
21 changed files with 885 additions and 52 deletions

View File

@@ -23,7 +23,7 @@ from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from tests.common import MockUser, async_capture_events, async_fire_time_changed
from tests.typing import WebSocketGenerator
from tests.typing import MockHAClientWebSocket, WebSocketGenerator
MOCK_THEMES = {
"happy": {"primary-color": "red", "app-header-background-color": "blue"},
@@ -664,3 +664,76 @@ async def test_static_path_cache(hass: HomeAssistant, mock_http_client) -> None:
# and again to make sure the cache works
resp = await mock_http_client.get("/static/does-not-exist", allow_redirects=False)
assert resp.status == 404
async def test_get_icons(hass: HomeAssistant, ws_client: MockHAClientWebSocket) -> None:
"""Test get_icons command."""
with patch(
"homeassistant.components.frontend.async_get_icons",
side_effect=lambda hass, category, integrations: {},
):
await ws_client.send_json(
{
"id": 5,
"type": "frontend/get_icons",
"category": "entity_component",
}
)
msg = await ws_client.receive_json()
assert msg["id"] == 5
assert msg["type"] == TYPE_RESULT
assert msg["success"]
assert msg["result"] == {"resources": {}}
async def test_get_icons_for_integrations(
hass: HomeAssistant, ws_client: MockHAClientWebSocket
) -> None:
"""Test get_icons for integrations command."""
with patch(
"homeassistant.components.frontend.async_get_icons",
side_effect=lambda hass, category, integrations: {
integration: {} for integration in integrations
},
):
await ws_client.send_json(
{
"id": 5,
"type": "frontend/get_icons",
"integration": ["frontend", "http"],
"category": "entity",
}
)
msg = await ws_client.receive_json()
assert msg["id"] == 5
assert msg["type"] == TYPE_RESULT
assert msg["success"]
assert set(msg["result"]["resources"]) == {"frontend", "http"}
async def test_get_icons_for_single_integration(
hass: HomeAssistant, ws_client: MockHAClientWebSocket
) -> None:
"""Test get_icons for integration command."""
with patch(
"homeassistant.components.frontend.async_get_icons",
side_effect=lambda hass, category, integrations: {
integration: {} for integration in integrations
},
):
await ws_client.send_json(
{
"id": 5,
"type": "frontend/get_icons",
"integration": "http",
"category": "entity",
}
)
msg = await ws_client.receive_json()
assert msg["id"] == 5
assert msg["type"] == TYPE_RESULT
assert msg["success"]
assert msg["result"] == {"resources": {"http": {}}}