Add type hints to tests (#92477)
This commit is contained in:
parent
3b4828d736
commit
6836e15d98
12 changed files with 30 additions and 27 deletions
|
@ -427,7 +427,7 @@ async def test_closed_state(feature, hass: HomeAssistant) -> None:
|
||||||
assert hass.states.get(entity_id).state == STATE_CLOSED
|
assert hass.states.get(entity_id).state == STATE_CLOSED
|
||||||
|
|
||||||
|
|
||||||
async def test_tilt_position(shutterbox, hass):
|
async def test_tilt_position(shutterbox, hass: HomeAssistant) -> None:
|
||||||
"""Test tilt capability is available."""
|
"""Test tilt capability is available."""
|
||||||
|
|
||||||
feature_mock, entity_id = shutterbox
|
feature_mock, entity_id = shutterbox
|
||||||
|
@ -443,7 +443,7 @@ async def test_tilt_position(shutterbox, hass):
|
||||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 10
|
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 10
|
||||||
|
|
||||||
|
|
||||||
async def test_set_tilt_position(shutterbox, hass):
|
async def test_set_tilt_position(shutterbox, hass: HomeAssistant) -> None:
|
||||||
"""Test tilt position setting."""
|
"""Test tilt position setting."""
|
||||||
|
|
||||||
feature_mock, entity_id = shutterbox
|
feature_mock, entity_id = shutterbox
|
||||||
|
|
|
@ -16,7 +16,7 @@ from . import configure_integration
|
||||||
from .mocks import HomeControlMock, HomeControlMockSwitch
|
from .mocks import HomeControlMock, HomeControlMockSwitch
|
||||||
|
|
||||||
|
|
||||||
async def test_switch(hass: HomeAssistant):
|
async def test_switch(hass: HomeAssistant) -> None:
|
||||||
"""Test setup and state change of a switch device."""
|
"""Test setup and state change of a switch device."""
|
||||||
entry = configure_integration(hass)
|
entry = configure_integration(hass)
|
||||||
test_gateway = HomeControlMockSwitch()
|
test_gateway = HomeControlMockSwitch()
|
||||||
|
@ -66,7 +66,7 @@ async def test_switch(hass: HomeAssistant):
|
||||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_UNAVAILABLE
|
assert hass.states.get(f"{DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
|
|
||||||
async def test_remove_from_hass(hass: HomeAssistant):
|
async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
||||||
"""Test removing entity."""
|
"""Test removing entity."""
|
||||||
entry = configure_integration(hass)
|
entry = configure_integration(hass)
|
||||||
test_gateway = HomeControlMockSwitch()
|
test_gateway = HomeControlMockSwitch()
|
||||||
|
|
|
@ -106,7 +106,7 @@ async def test_user_custom_url(hass: HomeAssistant, ezviz_config_flow) -> None:
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_async_step_reauth(hass, ezviz_config_flow):
|
async def test_async_step_reauth(hass: HomeAssistant, ezviz_config_flow) -> None:
|
||||||
"""Test the reauth step."""
|
"""Test the reauth step."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -149,7 +149,9 @@ async def test_async_step_reauth(hass, ezviz_config_flow):
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
async def test_step_discovery_abort_if_cloud_account_missing(hass):
|
async def test_step_discovery_abort_if_cloud_account_missing(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
) -> None:
|
||||||
"""Test discovery and confirm step, abort if cloud account was removed."""
|
"""Test discovery and confirm step, abort if cloud account was removed."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -172,7 +174,7 @@ async def test_step_discovery_abort_if_cloud_account_missing(hass):
|
||||||
assert result["reason"] == "ezviz_cloud_account_missing"
|
assert result["reason"] == "ezviz_cloud_account_missing"
|
||||||
|
|
||||||
|
|
||||||
async def test_step_reauth_abort_if_cloud_account_missing(hass):
|
async def test_step_reauth_abort_if_cloud_account_missing(hass: HomeAssistant) -> None:
|
||||||
"""Test reauth and confirm step, abort if cloud account was removed."""
|
"""Test reauth and confirm step, abort if cloud account was removed."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -183,8 +185,8 @@ async def test_step_reauth_abort_if_cloud_account_missing(hass):
|
||||||
|
|
||||||
|
|
||||||
async def test_async_step_integration_discovery(
|
async def test_async_step_integration_discovery(
|
||||||
hass, ezviz_config_flow, ezviz_test_rtsp_config_flow
|
hass: HomeAssistant, ezviz_config_flow, ezviz_test_rtsp_config_flow
|
||||||
):
|
) -> None:
|
||||||
"""Test discovery and confirm step."""
|
"""Test discovery and confirm step."""
|
||||||
with patch("homeassistant.components.ezviz.PLATFORMS_BY_TYPE", []):
|
with patch("homeassistant.components.ezviz.PLATFORMS_BY_TYPE", []):
|
||||||
await init_integration(hass)
|
await init_integration(hass)
|
||||||
|
@ -530,7 +532,9 @@ async def test_user_custom_url_exception(
|
||||||
assert result["reason"] == "unknown"
|
assert result["reason"] == "unknown"
|
||||||
|
|
||||||
|
|
||||||
async def test_async_step_reauth_exception(hass, ezviz_config_flow):
|
async def test_async_step_reauth_exception(
|
||||||
|
hass: HomeAssistant, ezviz_config_flow
|
||||||
|
) -> None:
|
||||||
"""Test the reauth step exceptions."""
|
"""Test the reauth step exceptions."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
|
|
@ -43,7 +43,7 @@ async def test_sensor_states(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
async def test_migrate_unique_id(
|
async def test_migrate_unique_id(
|
||||||
hass: HomeAssistant, object_id: str, old_unique_id: str, new_unique_id: str
|
hass: HomeAssistant, object_id: str, old_unique_id: str, new_unique_id: str
|
||||||
):
|
) -> None:
|
||||||
"""Test unique id migration."""
|
"""Test unique id migration."""
|
||||||
old_config_data = {**MOCK_USER_INPUT, "name": "Glances"}
|
old_config_data = {**MOCK_USER_INPUT, "name": "Glances"}
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data=old_config_data)
|
entry = MockConfigEntry(domain=DOMAIN, data=old_config_data)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""The tests for Lidarr sensor platform."""
|
"""The tests for Lidarr sensor platform."""
|
||||||
from unittest.mock import AsyncMock
|
|
||||||
|
|
||||||
from homeassistant.components.sensor import CONF_STATE_CLASS, SensorStateClass
|
from homeassistant.components.sensor import CONF_STATE_CLASS, SensorStateClass
|
||||||
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT
|
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -11,9 +9,9 @@ from .conftest import ComponentSetup
|
||||||
async def test_sensors(
|
async def test_sensors(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
setup_integration: ComponentSetup,
|
setup_integration: ComponentSetup,
|
||||||
entity_registry_enabled_by_default: AsyncMock,
|
entity_registry_enabled_by_default: None,
|
||||||
connection,
|
connection,
|
||||||
):
|
) -> None:
|
||||||
"""Test for successfully setting up the Lidarr platform."""
|
"""Test for successfully setting up the Lidarr platform."""
|
||||||
await setup_integration()
|
await setup_integration()
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ from tests.common import MockConfigEntry
|
||||||
from tests.components.bluetooth import inject_bluetooth_service_info
|
from tests.components.bluetooth import inject_bluetooth_service_info
|
||||||
|
|
||||||
|
|
||||||
async def test_sensors(hass: HomeAssistant):
|
async def test_sensors(hass: HomeAssistant) -> None:
|
||||||
"""Test setting up creates the sensors."""
|
"""Test setting up creates the sensors."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
|
|
|
@ -40,7 +40,7 @@ async def test_config_entry_unload(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_id_migration(
|
async def test_entity_id_migration(
|
||||||
hass: HomeAssistant, entity_registry: er.RegistryEntry
|
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the migration of unique IDs on config entry setup."""
|
"""Test the migration of unique IDs on config entry setup."""
|
||||||
config_entry = mock_config_entry(unique_id="binary_sensor_test_diffuser_v1")
|
config_entry = mock_config_entry(unique_id="binary_sensor_test_diffuser_v1")
|
||||||
|
|
|
@ -17,7 +17,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||||
|
|
||||||
async def test_subscription_repair_issues(
|
async def test_subscription_repair_issues(
|
||||||
hass: HomeAssistant, config_entry: MockConfigEntry, soco, zgs_discovery
|
hass: HomeAssistant, config_entry: MockConfigEntry, soco, zgs_discovery
|
||||||
):
|
) -> None:
|
||||||
"""Test repair issues handling for failed subscriptions."""
|
"""Test repair issues handling for failed subscriptions."""
|
||||||
issue_registry = async_get_issue_registry(hass)
|
issue_registry = async_get_issue_registry(hass)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""Test VoIP devices."""
|
"""Test VoIP devices."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from voip_utils import CallInfo
|
from voip_utils import CallInfo
|
||||||
|
@ -7,14 +6,14 @@ from voip_utils import CallInfo
|
||||||
from homeassistant.components.voip import DOMAIN
|
from homeassistant.components.voip import DOMAIN
|
||||||
from homeassistant.components.voip.devices import VoIPDevice, VoIPDevices
|
from homeassistant.components.voip.devices import VoIPDevice, VoIPDevices
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceRegistry
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
|
|
||||||
async def test_device_registry_info(
|
async def test_device_registry_info(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
voip_devices: VoIPDevices,
|
voip_devices: VoIPDevices,
|
||||||
call_info: CallInfo,
|
call_info: CallInfo,
|
||||||
device_registry: DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test info in device registry."""
|
"""Test info in device registry."""
|
||||||
voip_device = voip_devices.async_get_or_create(call_info)
|
voip_device = voip_devices.async_get_or_create(call_info)
|
||||||
|
@ -41,7 +40,7 @@ async def test_device_registry_info_from_unknown_phone(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
voip_devices: VoIPDevices,
|
voip_devices: VoIPDevices,
|
||||||
call_info: CallInfo,
|
call_info: CallInfo,
|
||||||
device_registry: DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test info in device registry from unknown phone."""
|
"""Test info in device registry from unknown phone."""
|
||||||
call_info.headers["user-agent"] = "Unknown"
|
call_info.headers["user-agent"] = "Unknown"
|
||||||
|
@ -58,7 +57,7 @@ async def test_remove_device_registry_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
voip_device: VoIPDevice,
|
voip_device: VoIPDevice,
|
||||||
voip_devices: VoIPDevices,
|
voip_devices: VoIPDevices,
|
||||||
device_registry: DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removing a device registry entry."""
|
"""Test removing a device registry entry."""
|
||||||
assert voip_device.voip_id in voip_devices.devices
|
assert voip_device.voip_id in voip_devices.devices
|
||||||
|
|
|
@ -161,7 +161,7 @@ async def test_webhook_head(hass: HomeAssistant, mock_client) -> None:
|
||||||
assert len(hooks) == 1 # Should not have been called
|
assert len(hooks) == 1 # Should not have been called
|
||||||
|
|
||||||
|
|
||||||
async def test_webhook_get(hass, mock_client):
|
async def test_webhook_get(hass: HomeAssistant, mock_client) -> None:
|
||||||
"""Test sending a get request to a webhook."""
|
"""Test sending a get request to a webhook."""
|
||||||
hooks = []
|
hooks = []
|
||||||
webhook_id = webhook.async_generate_id()
|
webhook_id = webhook.async_generate_id()
|
||||||
|
@ -191,7 +191,7 @@ async def test_webhook_get(hass, mock_client):
|
||||||
assert len(hooks) == 1 # Should not have been called
|
assert len(hooks) == 1 # Should not have been called
|
||||||
|
|
||||||
|
|
||||||
async def test_webhook_not_allowed_method(hass):
|
async def test_webhook_not_allowed_method(hass: HomeAssistant) -> None:
|
||||||
"""Test that an exception is raised if an unsupported method is used."""
|
"""Test that an exception is raised if an unsupported method is used."""
|
||||||
webhook_id = webhook.async_generate_id()
|
webhook_id = webhook.async_generate_id()
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,9 @@ async def test_webhook_post(
|
||||||
assert len(events) == 1
|
assert len(events) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_webhook_allowed_methods_internet(hass, hass_client_no_auth):
|
async def test_webhook_allowed_methods_internet(
|
||||||
|
hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator
|
||||||
|
) -> None:
|
||||||
"""Test the webhook obeys allowed_methods and local_only options."""
|
"""Test the webhook obeys allowed_methods and local_only options."""
|
||||||
events = []
|
events = []
|
||||||
|
|
||||||
|
|
|
@ -1641,7 +1641,7 @@ def test_states_function(hass: HomeAssistant) -> None:
|
||||||
assert tpl.async_render() == "available"
|
assert tpl.async_render() == "available"
|
||||||
|
|
||||||
|
|
||||||
def test_has_value(hass):
|
def test_has_value(hass: HomeAssistant) -> None:
|
||||||
"""Test has_value method."""
|
"""Test has_value method."""
|
||||||
hass.states.async_set("test.value1", 1)
|
hass.states.async_set("test.value1", 1)
|
||||||
hass.states.async_set("test.unavailable", STATE_UNAVAILABLE)
|
hass.states.async_set("test.unavailable", STATE_UNAVAILABLE)
|
||||||
|
|
Loading…
Add table
Reference in a new issue