Fix broken trace tests (#48458)

pull/48407/head
Erik Montnemery 2021-03-29 10:06:22 +02:00 committed by GitHub
parent 564688af25
commit 0c6a1c29ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -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

View File

@ -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)