Refactor ZHA EventChannels (#32709)

* Refactor EventChannels.

* Rename EventRelayChannel.

* Fully rename EventRelayChannel.

- update docstrings
- rename all references from "relay" to "client"

* Remove CHANNEL_NAME.

* Update stale docstring.
This commit is contained in:
Alexei Chetroi authored and GitHub committed 2020-03-21 19:59:32 -04:00
1 parent d5e606640c
commit 991afccbd4
10 files changed
+62 -40

No files matched your search

+9 -5
View File
@@ -274,7 +274,9 @@ def test_epch_claim_channels(channel):
assert "1:0x0300" in ep_channels.claimed_channels
@mock.patch("homeassistant.components.zha.core.channels.ChannelPool.add_relay_channels")
@mock.patch(
"homeassistant.components.zha.core.channels.ChannelPool.add_client_channels"
)
@mock.patch(
"homeassistant.components.zha.core.discovery.PROBE.discover_entities",
mock.MagicMock(),
@@ -319,7 +321,9 @@ def test_ep_channels_all_channels(m1, zha_device_mock):
assert "2:0x0300" in ep_channels.all_channels
@mock.patch("homeassistant.components.zha.core.channels.ChannelPool.add_relay_channels")
@mock.patch(
"homeassistant.components.zha.core.channels.ChannelPool.add_client_channels"
)
@mock.patch(
"homeassistant.components.zha.core.discovery.PROBE.discover_entities",
mock.MagicMock(),
@@ -387,14 +391,14 @@ async def test_ep_channels_configure(channel):
ep_channels = zha_channels.ChannelPool(channels, mock.sentinel.ep)
claimed = {ch_1.id: ch_1, ch_2.id: ch_2, ch_3.id: ch_3}
relay = {ch_4.id: ch_4, ch_5.id: ch_5}
client_chans = {ch_4.id: ch_4, ch_5.id: ch_5}
with mock.patch.dict(ep_channels.claimed_channels, claimed, clear=True):
with mock.patch.dict(ep_channels.relay_channels, relay, clear=True):
with mock.patch.dict(ep_channels.client_channels, client_chans, clear=True):
await ep_channels.async_configure()
await ep_channels.async_initialize(mock.sentinel.from_cache)
for ch in [*claimed.values(), *relay.values()]:
for ch in [*claimed.values(), *client_chans.values()]:
assert ch.async_initialize.call_count == 1
assert ch.async_initialize.await_count == 1
assert ch.async_initialize.call_args[0][0] is mock.sentinel.from_cache
+1 -1
View File
@@ -103,7 +103,7 @@ async def test_action(hass, device_ias):
await hass.async_block_till_done()
calls = async_mock_service(hass, DOMAIN, "warning_device_warn")
channel = zha_device.channels.pools[0].relay_channels["1:0x0006"]
channel = zha_device.channels.pools[0].client_channels["1:0x0006"]
channel.zha_send_event(COMMAND_SINGLE, [])
await hass.async_block_till_done()
+1 -1
View File
@@ -172,7 +172,7 @@ async def test_if_fires_on_event(hass, mock_devices, calls):
await hass.async_block_till_done()
channel = zha_device.channels.pools[0].relay_channels["1:0x0006"]
channel = zha_device.channels.pools[0].client_channels["1:0x0006"]
channel.zha_send_event(COMMAND_SINGLE, [])
await hass.async_block_till_done()
+2 -2
View File
@@ -111,7 +111,7 @@ async def test_devices(
)
event_channels = {
ch.id for pool in zha_dev.channels.pools for ch in pool.relay_channels.values()
ch.id for pool in zha_dev.channels.pools for ch in pool.client_channels.values()
}
entity_map = device["entity_map"]
@@ -266,7 +266,7 @@ async def test_discover_endpoint(device_info, channels_mock, hass):
)
assert device_info["event_channels"] == sorted(
[ch.id for pool in channels.pools for ch in pool.relay_channels.values()]
[ch.id for pool in channels.pools for ch in pool.client_channels.values()]
)
assert new_ent.call_count == len(
[