Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deCONZ - create deconz_events through sensor platform (#26592)
* Move event creation into sensor platform where it belongs * Fixed the weird failing test observed during device automation PR
- Loading branch information
Showing
4 changed files
with
70 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""Test deCONZ remote events.""" | ||
from unittest.mock import Mock | ||
|
||
from homeassistant.components.deconz.deconz_event import CONF_DECONZ_EVENT, DeconzEvent | ||
from homeassistant.core import callback | ||
|
||
|
||
async def test_create_event(hass): | ||
"""Successfully created a deCONZ event.""" | ||
mock_remote = Mock() | ||
mock_remote.name = "Name" | ||
|
||
mock_gateway = Mock() | ||
mock_gateway.hass = hass | ||
|
||
event = DeconzEvent(mock_remote, mock_gateway) | ||
|
||
assert event.event_id == "name" | ||
|
||
|
||
async def test_update_event(hass): | ||
"""Successfully update a deCONZ event.""" | ||
mock_remote = Mock() | ||
mock_remote.name = "Name" | ||
|
||
mock_gateway = Mock() | ||
mock_gateway.hass = hass | ||
|
||
event = DeconzEvent(mock_remote, mock_gateway) | ||
mock_remote.changed_keys = {"state": True} | ||
|
||
calls = [] | ||
|
||
@callback | ||
def listener(event): | ||
"""Mock listener.""" | ||
calls.append(event) | ||
|
||
unsub = hass.bus.async_listen(CONF_DECONZ_EVENT, listener) | ||
|
||
event.async_update_callback() | ||
await hass.async_block_till_done() | ||
|
||
assert len(calls) == 1 | ||
|
||
unsub() | ||
|
||
|
||
async def test_remove_event(hass): | ||
"""Successfully update a deCONZ event.""" | ||
mock_remote = Mock() | ||
mock_remote.name = "Name" | ||
|
||
mock_gateway = Mock() | ||
mock_gateway.hass = hass | ||
|
||
event = DeconzEvent(mock_remote, mock_gateway) | ||
event.async_will_remove_from_hass() | ||
|
||
assert event._device is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters