Fix broken trace tests (#48458)
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()
|
||||
|
||||
# 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()
|
||||
assert response["success"]
|
||||
assert len(response["result"]) == 2
|
||||
assert len(_find_traces(response["result"], domain, "sun")) == 1
|
||||
if domain == "automation":
|
||||
assert len(response["result"]) == 1
|
||||
else:
|
||||
assert len(response["result"]) == 2
|
||||
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")
|
||||
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
|
||||
|
||||
# Get trace
|
||||
|
|
|
@ -31,6 +31,12 @@ def assert_element(trace_element, expected_element, path):
|
|||
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):
|
||||
"""Assert a trace condition sequence is as expected."""
|
||||
condition_trace = trace.trace_get(clear=False)
|
||||
|
|
Loading…
Reference in New Issue