Add type hints to integration tests (part 9) (#87983)

This commit is contained in:
epenet 2023-02-13 12:06:51 +01:00 committed by GitHub
parent 6359775cfc
commit 03710e58b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 1526 additions and 781 deletions

View file

@ -17,6 +17,7 @@ from homeassistant.components.climate import (
SERVICE_SET_TEMPERATURE,
HVACMode,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .common import get_next_aid, setup_test_component
@ -71,7 +72,9 @@ def create_thermostat_service_min_max(accessory):
char.maxValue = 1
async def test_climate_respect_supported_op_modes_1(hass, utcnow):
async def test_climate_respect_supported_op_modes_1(
hass: HomeAssistant, utcnow
) -> None:
"""Test that climate respects minValue/maxValue hints."""
helper = await setup_test_component(hass, create_thermostat_service_min_max)
state = await helper.poll_and_get_state()
@ -86,14 +89,16 @@ def create_thermostat_service_valid_vals(accessory):
char.valid_values = [0, 1, 2]
async def test_climate_respect_supported_op_modes_2(hass, utcnow):
async def test_climate_respect_supported_op_modes_2(
hass: HomeAssistant, utcnow
) -> None:
"""Test that climate respects validValue hints."""
helper = await setup_test_component(hass, create_thermostat_service_valid_vals)
state = await helper.poll_and_get_state()
assert state.attributes["hvac_modes"] == ["off", "heat", "cool"]
async def test_climate_change_thermostat_state(hass, utcnow):
async def test_climate_change_thermostat_state(hass: HomeAssistant, utcnow) -> None:
"""Test that we can turn a HomeKit thermostat on and off again."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -176,7 +181,9 @@ async def test_climate_change_thermostat_state(hass, utcnow):
)
async def test_climate_check_min_max_values_per_mode(hass, utcnow):
async def test_climate_check_min_max_values_per_mode(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we we get the appropriate min/max values for each mode."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -211,7 +218,9 @@ async def test_climate_check_min_max_values_per_mode(hass, utcnow):
assert climate_state.attributes["max_temp"] == 40
async def test_climate_change_thermostat_temperature(hass, utcnow):
async def test_climate_change_thermostat_temperature(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we can turn a HomeKit thermostat on and off again."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -242,7 +251,9 @@ async def test_climate_change_thermostat_temperature(hass, utcnow):
)
async def test_climate_change_thermostat_temperature_range(hass, utcnow):
async def test_climate_change_thermostat_temperature_range(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we can set separate heat and cool setpoints in heat_cool mode."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -275,7 +286,9 @@ async def test_climate_change_thermostat_temperature_range(hass, utcnow):
)
async def test_climate_change_thermostat_temperature_range_iphone(hass, utcnow):
async def test_climate_change_thermostat_temperature_range_iphone(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we can set all three set points at once (iPhone heat_cool mode support)."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -308,7 +321,9 @@ async def test_climate_change_thermostat_temperature_range_iphone(hass, utcnow):
)
async def test_climate_cannot_set_thermostat_temp_range_in_wrong_mode(hass, utcnow):
async def test_climate_cannot_set_thermostat_temp_range_in_wrong_mode(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we cannot set range values when not in heat_cool mode."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -365,7 +380,9 @@ def create_thermostat_single_set_point_auto(accessory):
char.value = 0
async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow):
async def test_climate_check_min_max_values_per_mode_sspa_device(
hass: HomeAssistant, utcnow
) -> None:
"""Test appropriate min/max values for each mode on sspa devices."""
helper = await setup_test_component(hass, create_thermostat_single_set_point_auto)
@ -400,7 +417,9 @@ async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow):
assert climate_state.attributes["max_temp"] == 35
async def test_climate_set_thermostat_temp_on_sspa_device(hass, utcnow):
async def test_climate_set_thermostat_temp_on_sspa_device(
hass: HomeAssistant, utcnow
) -> None:
"""Test setting temperature in different modes on device with single set point in auto."""
helper = await setup_test_component(hass, create_thermostat_single_set_point_auto)
@ -454,7 +473,7 @@ async def test_climate_set_thermostat_temp_on_sspa_device(hass, utcnow):
)
async def test_climate_set_mode_via_temp(hass, utcnow):
async def test_climate_set_mode_via_temp(hass: HomeAssistant, utcnow) -> None:
"""Test setting temperature and mode at same tims."""
helper = await setup_test_component(hass, create_thermostat_single_set_point_auto)
@ -495,7 +514,7 @@ async def test_climate_set_mode_via_temp(hass, utcnow):
)
async def test_climate_change_thermostat_humidity(hass, utcnow):
async def test_climate_change_thermostat_humidity(hass: HomeAssistant, utcnow) -> None:
"""Test that we can turn a HomeKit thermostat on and off again."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -526,7 +545,7 @@ async def test_climate_change_thermostat_humidity(hass, utcnow):
)
async def test_climate_read_thermostat_state(hass, utcnow):
async def test_climate_read_thermostat_state(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read the state of a HomeKit thermostat accessory."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -583,7 +602,7 @@ async def test_climate_read_thermostat_state(hass, utcnow):
assert state.state == HVACMode.HEAT_COOL
async def test_hvac_mode_vs_hvac_action(hass, utcnow):
async def test_hvac_mode_vs_hvac_action(hass: HomeAssistant, utcnow) -> None:
"""Check that we haven't conflated hvac_mode and hvac_action."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -620,7 +639,9 @@ async def test_hvac_mode_vs_hvac_action(hass, utcnow):
assert state.attributes["hvac_action"] == "heating"
async def test_hvac_mode_vs_hvac_action_current_mode_wrong(hass, utcnow):
async def test_hvac_mode_vs_hvac_action_current_mode_wrong(
hass: HomeAssistant, utcnow
) -> None:
"""Check that we cope with buggy HEATING_COOLING_CURRENT."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -681,7 +702,9 @@ def create_heater_cooler_service_min_max(accessory):
char.maxValue = 2
async def test_heater_cooler_respect_supported_op_modes_1(hass, utcnow):
async def test_heater_cooler_respect_supported_op_modes_1(
hass: HomeAssistant, utcnow
) -> None:
"""Test that climate respects minValue/maxValue hints."""
helper = await setup_test_component(hass, create_heater_cooler_service_min_max)
state = await helper.poll_and_get_state()
@ -696,14 +719,18 @@ def create_theater_cooler_service_valid_vals(accessory):
char.valid_values = [1, 2]
async def test_heater_cooler_respect_supported_op_modes_2(hass, utcnow):
async def test_heater_cooler_respect_supported_op_modes_2(
hass: HomeAssistant, utcnow
) -> None:
"""Test that climate respects validValue hints."""
helper = await setup_test_component(hass, create_theater_cooler_service_valid_vals)
state = await helper.poll_and_get_state()
assert state.attributes["hvac_modes"] == ["heat", "cool", "off"]
async def test_heater_cooler_change_thermostat_state(hass, utcnow):
async def test_heater_cooler_change_thermostat_state(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we can change the operational mode."""
helper = await setup_test_component(hass, create_heater_cooler_service)
@ -760,7 +787,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow):
)
async def test_can_turn_on_after_off(hass, utcnow):
async def test_can_turn_on_after_off(hass: HomeAssistant, utcnow) -> None:
"""Test that we always force device from inactive to active when setting mode.
This is a regression test for #81863.
@ -795,7 +822,9 @@ async def test_can_turn_on_after_off(hass, utcnow):
)
async def test_heater_cooler_change_thermostat_temperature(hass, utcnow):
async def test_heater_cooler_change_thermostat_temperature(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we can change the target temperature."""
helper = await setup_test_component(hass, create_heater_cooler_service)
@ -838,7 +867,7 @@ async def test_heater_cooler_change_thermostat_temperature(hass, utcnow):
)
async def test_heater_cooler_read_thermostat_state(hass, utcnow):
async def test_heater_cooler_read_thermostat_state(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read the state of a HomeKit thermostat accessory."""
helper = await setup_test_component(hass, create_heater_cooler_service)
@ -892,7 +921,9 @@ async def test_heater_cooler_read_thermostat_state(hass, utcnow):
assert state.state == HVACMode.HEAT_COOL
async def test_heater_cooler_hvac_mode_vs_hvac_action(hass, utcnow):
async def test_heater_cooler_hvac_mode_vs_hvac_action(
hass: HomeAssistant, utcnow
) -> None:
"""Check that we haven't conflated hvac_mode and hvac_action."""
helper = await setup_test_component(hass, create_heater_cooler_service)
@ -931,7 +962,7 @@ async def test_heater_cooler_hvac_mode_vs_hvac_action(hass, utcnow):
assert state.attributes["hvac_action"] == "heating"
async def test_heater_cooler_change_swing_mode(hass, utcnow):
async def test_heater_cooler_change_swing_mode(hass: HomeAssistant, utcnow) -> None:
"""Test that we can change the swing mode."""
helper = await setup_test_component(hass, create_heater_cooler_service)
@ -962,7 +993,7 @@ async def test_heater_cooler_change_swing_mode(hass, utcnow):
)
async def test_heater_cooler_turn_off(hass, utcnow):
async def test_heater_cooler_turn_off(hass: HomeAssistant, utcnow) -> None:
"""Test that both hvac_action and hvac_mode return "off" when turned off."""
helper = await setup_test_component(hass, create_heater_cooler_service)
@ -981,7 +1012,7 @@ async def test_heater_cooler_turn_off(hass, utcnow):
assert state.attributes["hvac_action"] == "off"
async def test_migrate_unique_id(hass, utcnow):
async def test_migrate_unique_id(hass: HomeAssistant, utcnow) -> None:
"""Test a we can migrate a switch unique id."""
entity_registry = er.async_get(hass)
aid = get_next_aid()