Improve hass_ws_client type hint in tests (#89703)

This commit is contained in:
epenet 2023-03-14 16:31:40 +01:00 committed by GitHub
parent 1bc4802c04
commit 71dc98a39c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 52 additions and 71 deletions

View file

@ -1,8 +1,6 @@
"""Test the api module."""
from collections.abc import Awaitable, Callable
from unittest.mock import MagicMock, call
from aiohttp import ClientWebSocketResponse
from matter_server.common.errors import InvalidCommand, NodeCommissionFailed
import pytest
@ -10,13 +8,14 @@ from homeassistant.components.matter.api import ID, TYPE
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
from tests.typing import WebSocketGenerator
# This tests needs to be adjusted to remove lingering tasks
@pytest.mark.parametrize("expected_lingering_tasks", [True])
async def test_commission(
hass: HomeAssistant,
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
hass_ws_client: WebSocketGenerator,
matter_client: MagicMock,
integration: MockConfigEntry,
) -> None:
@ -58,7 +57,7 @@ async def test_commission(
@pytest.mark.parametrize("expected_lingering_tasks", [True])
async def test_commission_on_network(
hass: HomeAssistant,
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
hass_ws_client: WebSocketGenerator,
matter_client: MagicMock,
integration: MockConfigEntry,
) -> None:
@ -100,7 +99,7 @@ async def test_commission_on_network(
@pytest.mark.parametrize("expected_lingering_tasks", [True])
async def test_set_thread_dataset(
hass: HomeAssistant,
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
hass_ws_client: WebSocketGenerator,
matter_client: MagicMock,
integration: MockConfigEntry,
) -> None:
@ -142,7 +141,7 @@ async def test_set_thread_dataset(
@pytest.mark.parametrize("expected_lingering_tasks", [True])
async def test_set_wifi_credentials(
hass: HomeAssistant,
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
hass_ws_client: WebSocketGenerator,
matter_client: MagicMock,
integration: MockConfigEntry,
) -> None:

View file

@ -2,10 +2,9 @@
from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable, Generator
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, call, patch
from aiohttp import ClientWebSocketResponse
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
from matter_server.client.models.node import MatterNode
from matter_server.common.errors import MatterError
@ -28,6 +27,7 @@ from homeassistant.setup import async_setup_component
from .common import load_and_parse_node_fixture, setup_integration_with_node_fixture
from tests.common import MockConfigEntry
from tests.typing import WebSocketGenerator
@pytest.fixture(name="connect_timeout")
@ -613,7 +613,7 @@ async def test_remove_entry(
async def test_remove_config_entry_device(
hass: HomeAssistant,
matter_client: MagicMock,
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test that a device can be removed ok."""
assert await async_setup_component(hass, "config", {})
@ -656,7 +656,7 @@ async def test_remove_config_entry_device_no_node(
hass: HomeAssistant,
matter_client: MagicMock,
integration: MockConfigEntry,
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test that a device can be removed ok without an existing node."""
assert await async_setup_component(hass, "config", {})