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

@ -2,6 +2,7 @@
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .common import get_next_aid, setup_test_component
@ -88,7 +89,7 @@ def create_fanv2_service_without_rotation_speed(accessory):
swing_mode.value = 0
async def test_fan_read_state(hass, utcnow):
async def test_fan_read_state(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read the state of a HomeKit fan accessory."""
helper = await setup_test_component(hass, create_fan_service)
@ -103,7 +104,7 @@ async def test_fan_read_state(hass, utcnow):
assert state.state == "on"
async def test_turn_on(hass, utcnow):
async def test_turn_on(hass: HomeAssistant, utcnow) -> None:
"""Test that we can turn a fan on."""
helper = await setup_test_component(hass, create_fan_service)
@ -150,7 +151,7 @@ async def test_turn_on(hass, utcnow):
)
async def test_turn_on_off_without_rotation_speed(hass, utcnow):
async def test_turn_on_off_without_rotation_speed(hass: HomeAssistant, utcnow) -> None:
"""Test that we can turn a fan on."""
helper = await setup_test_component(
hass, create_fanv2_service_without_rotation_speed
@ -183,7 +184,7 @@ async def test_turn_on_off_without_rotation_speed(hass, utcnow):
)
async def test_turn_off(hass, utcnow):
async def test_turn_off(hass: HomeAssistant, utcnow) -> None:
"""Test that we can turn a fan off."""
helper = await setup_test_component(hass, create_fan_service)
@ -203,7 +204,7 @@ async def test_turn_off(hass, utcnow):
)
async def test_set_speed(hass, utcnow):
async def test_set_speed(hass: HomeAssistant, utcnow) -> None:
"""Test that we set fan speed."""
helper = await setup_test_component(hass, create_fan_service)
@ -262,7 +263,7 @@ async def test_set_speed(hass, utcnow):
)
async def test_set_percentage(hass, utcnow):
async def test_set_percentage(hass: HomeAssistant, utcnow) -> None:
"""Test that we set fan speed by percentage."""
helper = await setup_test_component(hass, create_fan_service)
@ -295,7 +296,7 @@ async def test_set_percentage(hass, utcnow):
)
async def test_speed_read(hass, utcnow):
async def test_speed_read(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read a fans oscillation."""
helper = await setup_test_component(hass, create_fan_service)
@ -335,7 +336,7 @@ async def test_speed_read(hass, utcnow):
assert state.attributes["percentage"] == 0
async def test_set_direction(hass, utcnow):
async def test_set_direction(hass: HomeAssistant, utcnow) -> None:
"""Test that we can set fan spin direction."""
helper = await setup_test_component(hass, create_fan_service)
@ -366,7 +367,7 @@ async def test_set_direction(hass, utcnow):
)
async def test_direction_read(hass, utcnow):
async def test_direction_read(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read a fans oscillation."""
helper = await setup_test_component(hass, create_fan_service)
@ -381,7 +382,7 @@ async def test_direction_read(hass, utcnow):
assert state.attributes["direction"] == "reverse"
async def test_fanv2_read_state(hass, utcnow):
async def test_fanv2_read_state(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read the state of a HomeKit fan accessory."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -396,7 +397,7 @@ async def test_fanv2_read_state(hass, utcnow):
assert state.state == "on"
async def test_v2_turn_on(hass, utcnow):
async def test_v2_turn_on(hass: HomeAssistant, utcnow) -> None:
"""Test that we can turn a fan on."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -471,7 +472,7 @@ async def test_v2_turn_on(hass, utcnow):
)
async def test_v2_turn_off(hass, utcnow):
async def test_v2_turn_off(hass: HomeAssistant, utcnow) -> None:
"""Test that we can turn a fan off."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -491,7 +492,7 @@ async def test_v2_turn_off(hass, utcnow):
)
async def test_v2_set_speed(hass, utcnow):
async def test_v2_set_speed(hass: HomeAssistant, utcnow) -> None:
"""Test that we set fan speed."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -550,7 +551,7 @@ async def test_v2_set_speed(hass, utcnow):
)
async def test_v2_set_percentage(hass, utcnow):
async def test_v2_set_percentage(hass: HomeAssistant, utcnow) -> None:
"""Test that we set fan speed by percentage."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -583,7 +584,7 @@ async def test_v2_set_percentage(hass, utcnow):
)
async def test_v2_set_percentage_with_min_step(hass, utcnow):
async def test_v2_set_percentage_with_min_step(hass: HomeAssistant, utcnow) -> None:
"""Test that we set fan speed by percentage."""
helper = await setup_test_component(hass, create_fanv2_service_with_min_step)
@ -616,7 +617,7 @@ async def test_v2_set_percentage_with_min_step(hass, utcnow):
)
async def test_v2_speed_read(hass, utcnow):
async def test_v2_speed_read(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read a fans oscillation."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -655,7 +656,7 @@ async def test_v2_speed_read(hass, utcnow):
assert state.attributes["percentage"] == 0
async def test_v2_set_direction(hass, utcnow):
async def test_v2_set_direction(hass: HomeAssistant, utcnow) -> None:
"""Test that we can set fan spin direction."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -686,7 +687,7 @@ async def test_v2_set_direction(hass, utcnow):
)
async def test_v2_direction_read(hass, utcnow):
async def test_v2_direction_read(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read a fans oscillation."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -701,7 +702,7 @@ async def test_v2_direction_read(hass, utcnow):
assert state.attributes["direction"] == "reverse"
async def test_v2_oscillate(hass, utcnow):
async def test_v2_oscillate(hass: HomeAssistant, utcnow) -> None:
"""Test that we can control a fans oscillation."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -732,7 +733,7 @@ async def test_v2_oscillate(hass, utcnow):
)
async def test_v2_oscillate_read(hass, utcnow):
async def test_v2_oscillate_read(hass: HomeAssistant, utcnow) -> None:
"""Test that we can read a fans oscillation."""
helper = await setup_test_component(hass, create_fanv2_service)
@ -747,7 +748,9 @@ async def test_v2_oscillate_read(hass, utcnow):
assert state.attributes["oscillating"] is True
async def test_v2_set_percentage_non_standard_rotation_range(hass, utcnow):
async def test_v2_set_percentage_non_standard_rotation_range(
hass: HomeAssistant, utcnow
) -> None:
"""Test that we set fan speed with a non-standard rotation range."""
helper = await setup_test_component(
hass, create_fanv2_service_non_standard_rotation_range
@ -808,7 +811,7 @@ async def test_v2_set_percentage_non_standard_rotation_range(hass, utcnow):
)
async def test_migrate_unique_id(hass, utcnow):
async def test_migrate_unique_id(hass: HomeAssistant, utcnow) -> None:
"""Test a we can migrate a fan unique id."""
entity_registry = er.async_get(hass)
aid = get_next_aid()