Add WS API command to capture zwave_js logs from server (#49444)
* Add WS API commands to capture zwave_js logs from server * register commands * create a task * Update homeassistant/components/zwave_js/api.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/zwave_js/api.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * fix * fixes and add test * fix PR on rebase Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
cad281b326
commit
99c5087c1e
2 changed files with 91 additions and 0 deletions
|
@ -445,6 +445,48 @@ async def test_dump_view_invalid_entry_id(integration, hass_client):
|
|||
assert resp.status == 400
|
||||
|
||||
|
||||
async def test_subscribe_logs(hass, integration, client, hass_ws_client):
|
||||
"""Test the subscribe_logs websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
client.async_send_command.return_value = {}
|
||||
|
||||
await ws_client.send_json(
|
||||
{ID: 1, TYPE: "zwave_js/subscribe_logs", ENTRY_ID: entry.entry_id}
|
||||
)
|
||||
|
||||
msg = await ws_client.receive_json()
|
||||
assert msg["success"]
|
||||
|
||||
event = Event(
|
||||
type="logging",
|
||||
data={
|
||||
"source": "driver",
|
||||
"event": "logging",
|
||||
"message": "test",
|
||||
"formattedMessage": "test",
|
||||
"direction": ">",
|
||||
"level": "debug",
|
||||
"primaryTags": "tag",
|
||||
"secondaryTags": "tag2",
|
||||
"secondaryTagPadding": 0,
|
||||
"multiline": False,
|
||||
"timestamp": "time",
|
||||
"label": "label",
|
||||
},
|
||||
)
|
||||
client.driver.receive_event(event)
|
||||
|
||||
msg = await ws_client.receive_json()
|
||||
assert msg["event"] == {
|
||||
"message": ["test"],
|
||||
"level": "debug",
|
||||
"primary_tags": "tag",
|
||||
"timestamp": "time",
|
||||
}
|
||||
|
||||
|
||||
async def test_update_log_config(hass, client, integration, hass_ws_client):
|
||||
"""Test that the update_log_config WS API call works and that schema validation works."""
|
||||
entry = integration
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue