hass-core/tests/components/zha/test_gateway.py
Alexei Chetroi 28eeed1db3
ZHA tests refactoring (#31682)
* Fixtures for restoring/joning a device.

* binary_sensor.zha tests.

* cover.zha platform tests.

* device_tracker.zha platform tests.

* fan.zha platform tests.

* switch.zha platform tests.

* Update light.zha platform tests.

* Update sensor.zha platform tests.

* ZHA api tests refactoring.

* Update lock.zha platform tests.

* Update ZHA gateway tests.

* Update zha device action tests.

* Update zha device trigger tests.

* Cleanup.
2020-02-09 21:45:35 -05:00

39 lines
1 KiB
Python

"""Test ZHA Gateway."""
import pytest
import zigpy.zcl.clusters.general as general
from .common import async_enable_traffic
@pytest.fixture
def zigpy_dev_basic(zigpy_device_mock):
"""Zigpy device with just a basic cluster."""
return zigpy_device_mock(
{
1: {
"in_clusters": [general.Basic.cluster_id],
"out_clusters": [],
"device_type": 0,
}
},
)
@pytest.fixture
async def zha_dev_basic(hass, zha_device_restored, zigpy_dev_basic):
"""ZHA device with just a basic cluster."""
zha_device = await zha_device_restored(zigpy_dev_basic)
return zha_device
async def test_device_left(hass, zha_gateway, zigpy_dev_basic, zha_dev_basic):
"""Device leaving the network should become unavailable."""
assert zha_dev_basic.available is False
await async_enable_traffic(hass, zha_gateway, [zha_dev_basic])
assert zha_dev_basic.available is True
zha_gateway.device_left(zigpy_dev_basic)
assert zha_dev_basic.available is False