Add type hints to integration tests (part 1) (#87777)

This commit is contained in:
epenet 2023-02-09 16:09:13 +01:00 committed by GitHub
parent 2b3e6a4ca8
commit 07a1a0efa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 905 additions and 471 deletions

View file

@ -25,6 +25,7 @@ from homeassistant.const import (
STATE_NOT_HOME,
STATE_UNAVAILABLE,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.util import slugify
from homeassistant.util.dt import utcnow
@ -217,12 +218,12 @@ def _setup_entry(hass, config, sensors, unique_id=None):
[None, MAC_ADDR],
)
async def test_sensors(
hass,
hass: HomeAssistant,
connect,
mock_devices,
create_device_registry_devices,
entry_unique_id,
):
) -> None:
"""Test creating AsusWRT default sensors and tracker."""
config_entry, sensor_prefix = _setup_entry(
hass, CONFIG_DATA, SENSORS_DEFAULT, entry_unique_id
@ -291,9 +292,9 @@ async def test_sensors(
async def test_loadavg_sensors(
hass,
hass: HomeAssistant,
connect,
):
) -> None:
"""Test creating an AsusWRT load average sensors."""
config_entry, sensor_prefix = _setup_entry(hass, CONFIG_DATA, SENSORS_LOADAVG)
config_entry.add_to_hass(hass)
@ -311,10 +312,10 @@ async def test_loadavg_sensors(
async def test_temperature_sensors_fail(
hass,
hass: HomeAssistant,
connect,
mock_available_temps,
):
) -> None:
"""Test fail creating AsusWRT temperature sensors."""
config_entry, sensor_prefix = _setup_entry(hass, CONFIG_DATA, SENSORS_TEMP)
config_entry.add_to_hass(hass)
@ -333,9 +334,9 @@ async def test_temperature_sensors_fail(
async def test_temperature_sensors(
hass,
hass: HomeAssistant,
connect,
):
) -> None:
"""Test creating a AsusWRT temperature sensors."""
config_entry, sensor_prefix = _setup_entry(hass, CONFIG_DATA, SENSORS_TEMP)
config_entry.add_to_hass(hass)
@ -356,7 +357,7 @@ async def test_temperature_sensors(
"side_effect",
[OSError, None],
)
async def test_connect_fail(hass, side_effect):
async def test_connect_fail(hass: HomeAssistant, side_effect) -> None:
"""Test AsusWRT connect fail."""
# init config entry
@ -379,7 +380,7 @@ async def test_connect_fail(hass, side_effect):
assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_sensors_polling_fails(hass, connect_sens_fail):
async def test_sensors_polling_fails(hass: HomeAssistant, connect_sens_fail) -> None:
"""Test AsusWRT sensors are unavailable when polling fails."""
config_entry, sensor_prefix = _setup_entry(hass, CONFIG_DATA, SENSORS_ALL)
config_entry.add_to_hass(hass)
@ -398,7 +399,7 @@ async def test_sensors_polling_fails(hass, connect_sens_fail):
assert hass.states.get(f"{sensor_prefix}_devices_connected").state == "0"
async def test_options_reload(hass, connect):
async def test_options_reload(hass: HomeAssistant, connect) -> None:
"""Test AsusWRT integration is reload changing an options that require this."""
config_entry = MockConfigEntry(domain=DOMAIN, data=CONFIG_DATA, unique_id=MAC_ADDR)
config_entry.add_to_hass(hass)