1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Add type hints to integration tests (zha) (#88309)

This commit is contained in:
epenet
2023-02-17 18:54:26 +01:00
committed by GitHub
parent 185cd61cbd
commit 7427d4f323
28 changed files with 411 additions and 238 deletions

View File

@@ -16,6 +16,7 @@ from homeassistant.components.zha.core.const import (
CONF_DEFAULT_CONSIDER_UNAVAILABLE_MAINS,
)
from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.device_registry as dr
import homeassistant.util.dt as dt_util
@@ -128,8 +129,8 @@ def _send_time_changed(hass, seconds):
new=mock.AsyncMock(),
)
async def test_check_available_success(
hass, device_with_basic_channel, zha_device_restored
):
hass: HomeAssistant, device_with_basic_channel, zha_device_restored
) -> None:
"""Check device availability success on 1st try."""
zha_device = await zha_device_restored(device_with_basic_channel)
await async_enable_traffic(hass, [zha_device])
@@ -180,8 +181,8 @@ async def test_check_available_success(
new=mock.AsyncMock(),
)
async def test_check_available_unsuccessful(
hass, device_with_basic_channel, zha_device_restored
):
hass: HomeAssistant, device_with_basic_channel, zha_device_restored
) -> None:
"""Check device availability all tries fail."""
zha_device = await zha_device_restored(device_with_basic_channel)
@@ -222,8 +223,11 @@ async def test_check_available_unsuccessful(
new=mock.AsyncMock(),
)
async def test_check_available_no_basic_channel(
hass, device_without_basic_channel, zha_device_restored, caplog
):
hass: HomeAssistant,
device_without_basic_channel,
zha_device_restored,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Check device availability for a device without basic cluster."""
caplog.set_level(logging.DEBUG, logger="homeassistant.components.zha")
@@ -243,7 +247,7 @@ async def test_check_available_no_basic_channel(
assert "does not have a mandatory basic cluster" in caplog.text
async def test_ota_sw_version(hass, ota_zha_device):
async def test_ota_sw_version(hass: HomeAssistant, ota_zha_device) -> None:
"""Test device entry gets sw_version updated via OTA channel."""
ota_ch = ota_zha_device.channels.pools[0].client_channels["1:0x0019"]
@@ -303,8 +307,13 @@ async def test_ota_sw_version(hass, ota_zha_device):
),
)
async def test_device_restore_availability(
hass, request, device, last_seen_delta, is_available, zha_device_restored
):
hass: HomeAssistant,
request,
device,
last_seen_delta,
is_available,
zha_device_restored,
) -> None:
"""Test initial availability for restored devices."""
zigpy_device = request.getfixturevalue(device)()
@@ -323,7 +332,9 @@ async def test_device_restore_availability(
assert hass.states.get(entity_id).state == STATE_UNAVAILABLE
async def test_device_is_active_coordinator(hass, zha_device_joined, zigpy_device):
async def test_device_is_active_coordinator(
hass: HomeAssistant, zha_device_joined, zigpy_device
) -> None:
"""Test that the current coordinator is uniquely detected."""
current_coord_dev = zigpy_device(ieee="aa:bb:cc:dd:ee:ff:00:11", nwk=0x0000)