Pass in parameters explicitly to DeconzSession (#29617)
Dont pass in loop to DeconzSession Services will use new refresh state method
This commit is contained in:
1 parent
00dc721609
commit
57a3f7d5c8
16 files changed
+219
-137
No files matched your search
@@ -85,11 +85,22 @@ async def test_switches(hass):
|
||||
warning_device = hass.states.get("switch.warning_device")
|
||||
assert warning_device.state == "on"
|
||||
|
||||
on_off_switch_device = gateway.api.lights["1"]
|
||||
warning_device_device = gateway.api.lights["3"]
|
||||
|
||||
on_off_switch_device.async_update({"state": {"on": False}})
|
||||
warning_device_device.async_update({"state": {"alert": None}})
|
||||
state_changed_event = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
"r": "lights",
|
||||
"id": "1",
|
||||
"state": {"on": False},
|
||||
}
|
||||
gateway.api.async_event_handler(state_changed_event)
|
||||
state_changed_event = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
"r": "lights",
|
||||
"id": "3",
|
||||
"state": {"alert": None},
|
||||
}
|
||||
gateway.api.async_event_handler(state_changed_event)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
on_off_switch = hass.states.get("switch.on_off_switch")
|
||||
@@ -98,8 +109,10 @@ async def test_switches(hass):
|
||||
warning_device = hass.states.get("switch.warning_device")
|
||||
assert warning_device.state == "off"
|
||||
|
||||
on_off_switch_device = gateway.api.lights["1"]
|
||||
|
||||
with patch.object(
|
||||
on_off_switch_device, "_async_set_callback", return_value=True
|
||||
on_off_switch_device, "_request", return_value=True
|
||||
) as set_callback:
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
@@ -108,10 +121,10 @@ async def test_switches(hass):
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
set_callback.assert_called_with("/lights/1/state", {"on": True})
|
||||
set_callback.assert_called_with("put", "/lights/1/state", json={"on": True})
|
||||
|
||||
with patch.object(
|
||||
on_off_switch_device, "_async_set_callback", return_value=True
|
||||
on_off_switch_device, "_request", return_value=True
|
||||
) as set_callback:
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
@@ -120,10 +133,12 @@ async def test_switches(hass):
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
set_callback.assert_called_with("/lights/1/state", {"on": False})
|
||||
set_callback.assert_called_with("put", "/lights/1/state", json={"on": False})
|
||||
|
||||
warning_device_device = gateway.api.lights["3"]
|
||||
|
||||
with patch.object(
|
||||
warning_device_device, "_async_set_callback", return_value=True
|
||||
warning_device_device, "_request", return_value=True
|
||||
) as set_callback:
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
@@ -132,10 +147,12 @@ async def test_switches(hass):
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
set_callback.assert_called_with("/lights/3/state", {"alert": "lselect"})
|
||||
set_callback.assert_called_with(
|
||||
"put", "/lights/3/state", json={"alert": "lselect"}
|
||||
)
|
||||
|
||||
with patch.object(
|
||||
warning_device_device, "_async_set_callback", return_value=True
|
||||
warning_device_device, "_request", return_value=True
|
||||
) as set_callback:
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
@@ -144,7 +161,9 @@ async def test_switches(hass):
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
set_callback.assert_called_with("/lights/3/state", {"alert": "none"})
|
||||
set_callback.assert_called_with(
|
||||
"put", "/lights/3/state", json={"alert": "none"}
|
||||
)
|
||||
|
||||
await gateway.async_reset()
|
||||
|
||||
|
||||
Reference in new issue
Block a user