mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Fix broken trace tests (#48458)
This commit is contained in:
parent
564688af25
commit
0c6a1c29ec
@ -552,14 +552,24 @@ async def test_nested_traces(hass, hass_ws_client, domain, prefix):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# List traces
|
# List traces
|
||||||
await client.send_json({"id": next_id(), "type": "trace/list"})
|
await client.send_json({"id": next_id(), "type": "trace/list", "domain": "script"})
|
||||||
response = await client.receive_json()
|
response = await client.receive_json()
|
||||||
assert response["success"]
|
assert response["success"]
|
||||||
assert len(response["result"]) == 2
|
if domain == "automation":
|
||||||
assert len(_find_traces(response["result"], domain, "sun")) == 1
|
assert len(response["result"]) == 1
|
||||||
|
else:
|
||||||
|
assert len(response["result"]) == 2
|
||||||
assert len(_find_traces(response["result"], "script", "moon")) == 1
|
assert len(_find_traces(response["result"], "script", "moon")) == 1
|
||||||
sun_run_id = _find_run_id(response["result"], domain, "sun")
|
|
||||||
moon_run_id = _find_run_id(response["result"], "script", "moon")
|
moon_run_id = _find_run_id(response["result"], "script", "moon")
|
||||||
|
if domain == "automation":
|
||||||
|
await client.send_json(
|
||||||
|
{"id": next_id(), "type": "trace/list", "domain": "automation"}
|
||||||
|
)
|
||||||
|
response = await client.receive_json()
|
||||||
|
assert response["success"]
|
||||||
|
assert len(response["result"]) == 1
|
||||||
|
assert len(_find_traces(response["result"], domain, "sun")) == 1
|
||||||
|
sun_run_id = _find_run_id(response["result"], domain, "sun")
|
||||||
assert sun_run_id != moon_run_id
|
assert sun_run_id != moon_run_id
|
||||||
|
|
||||||
# Get trace
|
# Get trace
|
||||||
|
@ -31,6 +31,12 @@ def assert_element(trace_element, expected_element, path):
|
|||||||
assert trace_element._error is None
|
assert trace_element._error is None
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def prepare_condition_trace():
|
||||||
|
"""Clear previous trace."""
|
||||||
|
trace.trace_clear()
|
||||||
|
|
||||||
|
|
||||||
def assert_condition_trace(expected):
|
def assert_condition_trace(expected):
|
||||||
"""Assert a trace condition sequence is as expected."""
|
"""Assert a trace condition sequence is as expected."""
|
||||||
condition_trace = trace.trace_get(clear=False)
|
condition_trace = trace.trace_get(clear=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user