mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 21:10:25 +00:00
Add command to get integration manifests (#34262)
* Add command to get integration manifests * Add is_built_in value to manifest * Update APIs
This commit is contained in:
@@ -10,6 +10,7 @@ from homeassistant.components.websocket_api.auth import (
|
||||
from homeassistant.components.websocket_api.const import URL
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.loader import async_get_integration
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import async_mock_service
|
||||
@@ -467,3 +468,46 @@ async def test_render_template_returns_with_match_all(
|
||||
assert msg["id"] == 5
|
||||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert msg["success"]
|
||||
|
||||
|
||||
async def test_manifest_list(hass, websocket_client):
|
||||
"""Test loading manifests."""
|
||||
http = await async_get_integration(hass, "http")
|
||||
websocket_api = await async_get_integration(hass, "websocket_api")
|
||||
|
||||
await websocket_client.send_json({"id": 5, "type": "manifest/list"})
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == 5
|
||||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert msg["success"]
|
||||
assert sorted(msg["result"], key=lambda manifest: manifest["domain"]) == [
|
||||
http.manifest,
|
||||
websocket_api.manifest,
|
||||
]
|
||||
|
||||
|
||||
async def test_manifest_get(hass, websocket_client):
|
||||
"""Test getting a manifest."""
|
||||
hue = await async_get_integration(hass, "hue")
|
||||
|
||||
await websocket_client.send_json(
|
||||
{"id": 6, "type": "manifest/get", "integration": "hue"}
|
||||
)
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == 6
|
||||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert msg["success"]
|
||||
assert msg["result"] == hue.manifest
|
||||
|
||||
# Non existing
|
||||
await websocket_client.send_json(
|
||||
{"id": 7, "type": "manifest/get", "integration": "non_existing"}
|
||||
)
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == 7
|
||||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == "not_found"
|
||||
|
||||
Reference in New Issue
Block a user