Move remaining of ZHA imports to top level. (#28071)
* Move ZHA import to top level. * ZHA tests: move imports to top level.
This commit is contained in:
1 parent
fc8920646b
commit
fe7c45b363
20 files changed
+261
-272
No files matched your search
@@ -1,7 +1,8 @@
|
||||
"""Test zha switch."""
|
||||
from unittest.mock import call, patch
|
||||
|
||||
from zigpy.zcl.foundation import Command
|
||||
import zigpy.zcl.clusters.general as general
|
||||
import zigpy.zcl.foundation as zcl_f
|
||||
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
||||
@@ -23,12 +24,14 @@ OFF = 0
|
||||
|
||||
async def test_switch(hass, config_entry, zha_gateway):
|
||||
"""Test zha switch platform."""
|
||||
from zigpy.zcl.clusters.general import OnOff, Basic
|
||||
from zigpy.zcl.foundation import Status
|
||||
|
||||
# create zigpy device
|
||||
zigpy_device = await async_init_zigpy_device(
|
||||
hass, [OnOff.cluster_id, Basic.cluster_id], [], None, zha_gateway
|
||||
hass,
|
||||
[general.OnOff.cluster_id, general.Basic.cluster_id],
|
||||
[],
|
||||
None,
|
||||
zha_gateway,
|
||||
)
|
||||
|
||||
# load up switch domain
|
||||
@@ -50,7 +53,7 @@ async def test_switch(hass, config_entry, zha_gateway):
|
||||
|
||||
# turn on at switch
|
||||
attr = make_attribute(0, 1)
|
||||
hdr = make_zcl_header(Command.Report_Attributes)
|
||||
hdr = make_zcl_header(zcl_f.Command.Report_Attributes)
|
||||
cluster.handle_message(hdr, [[attr]])
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(entity_id).state == STATE_ON
|
||||
@@ -63,7 +66,8 @@ async def test_switch(hass, config_entry, zha_gateway):
|
||||
|
||||
# turn on from HA
|
||||
with patch(
|
||||
"zigpy.zcl.Cluster.request", return_value=mock_coro([0x00, Status.SUCCESS])
|
||||
"zigpy.zcl.Cluster.request",
|
||||
return_value=mock_coro([0x00, zcl_f.Status.SUCCESS]),
|
||||
):
|
||||
# turn on via UI
|
||||
await hass.services.async_call(
|
||||
@@ -76,7 +80,8 @@ async def test_switch(hass, config_entry, zha_gateway):
|
||||
|
||||
# turn off from HA
|
||||
with patch(
|
||||
"zigpy.zcl.Cluster.request", return_value=mock_coro([0x01, Status.SUCCESS])
|
||||
"zigpy.zcl.Cluster.request",
|
||||
return_value=mock_coro([0x01, zcl_f.Status.SUCCESS]),
|
||||
):
|
||||
# turn off via UI
|
||||
await hass.services.async_call(
|
||||
@@ -88,4 +93,4 @@ async def test_switch(hass, config_entry, zha_gateway):
|
||||
)
|
||||
|
||||
# test joining a new switch to the network and HA
|
||||
await async_test_device_join(hass, zha_gateway, OnOff.cluster_id, DOMAIN)
|
||||
await async_test_device_join(hass, zha_gateway, general.OnOff.cluster_id, DOMAIN)
|
||||
Reference in new issue
Block a user