Simplify wake_word/info + improve test coverage (#100902)

* Simplify wake_word/info + improve test coverage

* Fix test

* Revert unrelated changes
This commit is contained in:
Erik Montnemery 2023-09-26 21:07:27 +02:00 committed by GitHub
parent 4028596977
commit b281fa17fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -3,7 +3,6 @@ from __future__ import annotations
from abc import abstractmethod
from collections.abc import AsyncIterable
import dataclasses
import logging
from typing import final
@ -150,5 +149,5 @@ def websocket_entity_info(
connection.send_result(
msg["id"],
{"wake_words": [dataclasses.asdict(ww) for ww in entity.supported_wake_words]},
{"wake_words": entity.supported_wake_words},
)

View File

@ -287,3 +287,24 @@ async def test_list_wake_words(
{"id": "test_ww_2", "name": "Test Wake Word 2"},
]
}
async def test_list_wake_words_unknown_entity(
hass: HomeAssistant,
setup: MockProviderEntity,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test that the list_wake_words websocket command works."""
client = await hass_ws_client(hass)
await client.send_json(
{
"id": 5,
"type": "wake_word/info",
"entity_id": "wake_word.blah",
}
)
msg = await client.receive_json()
assert not msg["success"]
assert msg["error"] == {"code": "not_found", "message": "Entity not found"}