Do not use AsyncTrackStates (#47255)

This commit is contained in:
Paulus Schoutsen
2021-03-11 23:18:09 -08:00
committed by GitHub
parent 2a22c54fcb
commit ff94e920e4
6 changed files with 73 additions and 43 deletions

View File

@@ -270,7 +270,6 @@ async def test_api_call_service_no_data(hass, mock_api_client):
async def test_api_call_service_with_data(hass, mock_api_client):
"""Test if the API allows us to call a service."""
test_value = []
@ha.callback
def listener(service_call):
@@ -278,17 +277,24 @@ async def test_api_call_service_with_data(hass, mock_api_client):
Also test if our data came through.
"""
if "test" in service_call.data:
test_value.append(1)
hass.states.async_set(
"test.data",
"on",
{"data": service_call.data["test"]},
context=service_call.context,
)
hass.services.async_register("test_domain", "test_service", listener)
await mock_api_client.post(
resp = await mock_api_client.post(
"/api/services/test_domain/test_service", json={"test": 1}
)
await hass.async_block_till_done()
assert len(test_value) == 1
data = await resp.json()
assert len(data) == 1
state = data[0]
assert state["entity_id"] == "test.data"
assert state["state"] == "on"
assert state["attributes"] == {"data": 1}
async def test_api_template(hass, mock_api_client):