mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Improve type hints in home_connect tests (#121014)
This commit is contained in:
parent
bdc6805771
commit
476efb1d36
@ -94,7 +94,7 @@ async def bypass_throttle(hass: HomeAssistant, config_entry: MockConfigEntry):
|
||||
|
||||
|
||||
@pytest.fixture(name="bypass_throttle")
|
||||
def mock_bypass_throttle():
|
||||
def mock_bypass_throttle() -> Generator[None]:
|
||||
"""Fixture to bypass the throttle decorator in __init__."""
|
||||
with patch(
|
||||
"homeassistant.components.home_connect.update_all_devices",
|
||||
@ -122,7 +122,7 @@ async def mock_integration_setup(
|
||||
|
||||
|
||||
@pytest.fixture(name="get_appliances")
|
||||
def mock_get_appliances() -> Generator[None, Any, None]:
|
||||
def mock_get_appliances() -> Generator[MagicMock]:
|
||||
"""Mock ConfigEntryAuth parent (HomeAssistantAPI) method."""
|
||||
with patch(
|
||||
"homeassistant.components.home_connect.api.ConfigEntryAuth.get_appliances",
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""Tests for home_connect binary_sensor entities."""
|
||||
|
||||
from collections.abc import Awaitable, Callable, Generator
|
||||
from typing import Any
|
||||
from collections.abc import Awaitable, Callable
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
import pytest
|
||||
@ -26,9 +25,8 @@ def platforms() -> list[str]:
|
||||
return [Platform.BINARY_SENSOR]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_binary_sensors(
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
setup_credentials: None,
|
||||
@ -51,10 +49,10 @@ async def test_binary_sensors(
|
||||
("", "unavailable"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_binary_sensors_door_states(
|
||||
expected: str,
|
||||
state: str,
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Test the integration init functionality."""
|
||||
|
||||
from collections.abc import Awaitable, Callable, Generator
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
@ -117,8 +117,8 @@ SERVICE_APPLIANCE_METHOD_MAPPING = {
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_api_setup(
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
@ -137,9 +137,8 @@ async def test_api_setup(
|
||||
assert config_entry.state == ConfigEntryState.NOT_LOADED
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_exception_handling(
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
config_entry: MockConfigEntry,
|
||||
setup_credentials: None,
|
||||
@ -154,8 +153,8 @@ async def test_exception_handling(
|
||||
|
||||
|
||||
@pytest.mark.parametrize("token_expiration_time", [12345])
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_token_refresh_success(
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
config_entry: MockConfigEntry,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
@ -227,9 +226,8 @@ async def test_update_throttle(
|
||||
assert get_appliances.call_count == 0
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_http_error(
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
setup_credentials: None,
|
||||
@ -247,9 +245,9 @@ async def test_http_error(
|
||||
"service_call",
|
||||
SERVICE_KV_CALL_PARAMS + SERVICE_COMMAND_CALL_PARAMS + SERVICE_PROGRAM_CALL_PARAMS,
|
||||
)
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_services(
|
||||
service_call: list[dict[str, Any]],
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
config_entry: MockConfigEntry,
|
||||
@ -279,8 +277,8 @@ async def test_services(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_services_exception(
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""Tests for home_connect sensor entities."""
|
||||
|
||||
from collections.abc import Awaitable, Callable, Generator
|
||||
from typing import Any
|
||||
from collections.abc import Awaitable, Callable
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
@ -69,9 +68,8 @@ def platforms() -> list[str]:
|
||||
return [Platform.SENSOR]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_sensors(
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
setup_credentials: None,
|
||||
@ -131,12 +129,12 @@ ENTITY_ID_STATES = {
|
||||
)
|
||||
),
|
||||
)
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_event_sensors(
|
||||
appliance: Mock,
|
||||
states: tuple,
|
||||
event_run: dict,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
@ -180,10 +178,10 @@ ENTITY_ID_EDGE_CASE_STATES = [
|
||||
|
||||
|
||||
@pytest.mark.parametrize("appliance", [TEST_HC_APP], indirect=True)
|
||||
@pytest.mark.usefixtures("bypass_throttle")
|
||||
async def test_remaining_prog_time_edge_cases(
|
||||
appliance: Mock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
bypass_throttle: Generator[None, Any, None],
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
|
Loading…
x
Reference in New Issue
Block a user