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

Improve error handling for WS API trace/get (#48502)

This commit is contained in:
Erik Montnemery
2021-03-31 15:58:36 +02:00
committed by GitHub
parent 6fe04f40a2
commit e2f8bce0a0
2 changed files with 27 additions and 1 deletions

View File

@@ -281,6 +281,25 @@ async def test_get_trace(hass, hass_ws_client, domain, prefix):
assert response["result"] == contexts
@pytest.mark.parametrize("domain", ["automation", "script"])
async def test_get_invalid_trace(hass, hass_ws_client, domain):
"""Test getting a non-existing trace."""
assert await async_setup_component(hass, domain, {domain: {}})
client = await hass_ws_client()
await client.send_json(
{
"id": 1,
"type": "trace/get",
"domain": domain,
"item_id": "sun",
"run_id": "invalid",
}
)
response = await client.receive_json()
assert not response["success"]
assert response["error"]["code"] == "not_found"
@pytest.mark.parametrize("domain", ["automation", "script"])
async def test_trace_overflow(hass, hass_ws_client, domain):
"""Test the number of stored traces per script or automation is limited."""