Add type hints to integration tests (part 13) (#87998)

This commit is contained in:
epenet 2023-02-13 14:38:37 +01:00 committed by GitHub
parent c557cd2b1e
commit ea11a30a35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 798 additions and 404 deletions

View file

@ -15,6 +15,7 @@ from homeassistant.const import (
STATE_ON,
STATE_UNAVAILABLE,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .conftest import MockModuleConnection
@ -25,7 +26,7 @@ SWITCH_RELAY1 = "switch.switch_relay1"
SWITCH_RELAY2 = "switch.switch_relay2"
async def test_setup_lcn_switch(hass, lcn_connection):
async def test_setup_lcn_switch(hass: HomeAssistant, lcn_connection) -> None:
"""Test the setup of switch."""
for entity_id in (
SWITCH_OUTPUT1,
@ -38,7 +39,7 @@ async def test_setup_lcn_switch(hass, lcn_connection):
assert state.state == STATE_OFF
async def test_entity_attributes(hass, entry, lcn_connection):
async def test_entity_attributes(hass: HomeAssistant, entry, lcn_connection) -> None:
"""Test the attributes of an entity."""
entity_registry = er.async_get(hass)
@ -56,7 +57,7 @@ async def test_entity_attributes(hass, entry, lcn_connection):
@patch.object(MockModuleConnection, "dim_output")
async def test_output_turn_on(dim_output, hass, lcn_connection):
async def test_output_turn_on(dim_output, hass: HomeAssistant, lcn_connection) -> None:
"""Test the output switch turns on."""
# command failed
dim_output.return_value = False
@ -91,7 +92,7 @@ async def test_output_turn_on(dim_output, hass, lcn_connection):
@patch.object(MockModuleConnection, "dim_output")
async def test_output_turn_off(dim_output, hass, lcn_connection):
async def test_output_turn_off(dim_output, hass: HomeAssistant, lcn_connection) -> None:
"""Test the output switch turns off."""
state = hass.states.get(SWITCH_OUTPUT1)
state.state = STATE_ON
@ -129,7 +130,9 @@ async def test_output_turn_off(dim_output, hass, lcn_connection):
@patch.object(MockModuleConnection, "control_relays")
async def test_relay_turn_on(control_relays, hass, lcn_connection):
async def test_relay_turn_on(
control_relays, hass: HomeAssistant, lcn_connection
) -> None:
"""Test the relay switch turns on."""
states = [RelayStateModifier.NOCHANGE] * 8
states[0] = RelayStateModifier.ON
@ -167,7 +170,9 @@ async def test_relay_turn_on(control_relays, hass, lcn_connection):
@patch.object(MockModuleConnection, "control_relays")
async def test_relay_turn_off(control_relays, hass, lcn_connection):
async def test_relay_turn_off(
control_relays, hass: HomeAssistant, lcn_connection
) -> None:
"""Test the relay switch turns off."""
states = [RelayStateModifier.NOCHANGE] * 8
states[0] = RelayStateModifier.OFF
@ -207,7 +212,9 @@ async def test_relay_turn_off(control_relays, hass, lcn_connection):
assert state.state == STATE_OFF
async def test_pushed_output_status_change(hass, entry, lcn_connection):
async def test_pushed_output_status_change(
hass: HomeAssistant, entry, lcn_connection
) -> None:
"""Test the output switch changes its state on status received."""
device_connection = get_device_connection(hass, (0, 7, False), entry)
address = LcnAddr(0, 7, False)
@ -229,7 +236,9 @@ async def test_pushed_output_status_change(hass, entry, lcn_connection):
assert state.state == STATE_OFF
async def test_pushed_relay_status_change(hass, entry, lcn_connection):
async def test_pushed_relay_status_change(
hass: HomeAssistant, entry, lcn_connection
) -> None:
"""Test the relay switch changes its state on status received."""
device_connection = get_device_connection(hass, (0, 7, False), entry)
address = LcnAddr(0, 7, False)
@ -254,7 +263,7 @@ async def test_pushed_relay_status_change(hass, entry, lcn_connection):
assert state.state == STATE_OFF
async def test_unload_config_entry(hass, entry, lcn_connection):
async def test_unload_config_entry(hass: HomeAssistant, entry, lcn_connection) -> None:
"""Test the switch is removed when the config entry is unloaded."""
await hass.config_entries.async_unload(entry.entry_id)
assert hass.states.get(SWITCH_OUTPUT1).state == STATE_UNAVAILABLE