Fix tests typing helper (#86956)
parent
33ede351f0
commit
7db166b515
tests
|
@ -17,7 +17,6 @@ from aioairzone.const import (
|
|||
RAW_HVAC,
|
||||
RAW_WEBSERVER,
|
||||
)
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from homeassistant.components.airzone.const import DOMAIN
|
||||
from homeassistant.components.diagnostics import REDACTED
|
||||
|
@ -27,10 +26,11 @@ from homeassistant.core import HomeAssistant
|
|||
from .util import CONFIG, HVAC_MOCK, HVAC_WEBSERVER_MOCK, async_init_integration
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_config_entry_diagnostics(
|
||||
hass: HomeAssistant, hass_client: ClientSession
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
await async_init_integration(hass)
|
||||
|
|
|
@ -7,7 +7,6 @@ import logging
|
|||
from typing import Any
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
from aiohttp import ClientWebSocketResponse
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
|
@ -31,6 +30,7 @@ from homeassistant.helpers import config_entry_oauth2_flow
|
|||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, mock_platform
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
CLIENT_ID = "some-client-id"
|
||||
CLIENT_SECRET = "some-client-secret"
|
||||
|
@ -211,9 +211,7 @@ ClientFixture = Callable[[], Client]
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
async def ws_client(
|
||||
hass_ws_client: Callable[[...], ClientWebSocketResponse]
|
||||
) -> ClientFixture:
|
||||
async def ws_client(hass_ws_client: WebSocketGenerator) -> ClientFixture:
|
||||
"""Fixture for creating the test websocket client."""
|
||||
|
||||
async def create_client() -> Client:
|
||||
|
|
|
@ -54,7 +54,7 @@ from homeassistant.setup import async_setup_component
|
|||
from homeassistant.util import dt as dt_util, location
|
||||
|
||||
from .ignore_uncaught_exceptions import IGNORE_UNCAUGHT_EXCEPTIONS
|
||||
from .typing import TestClientGenerator, TestWebSocketGenerator
|
||||
from .typing import ClientSessionGenerator, WebSocketGenerator
|
||||
|
||||
pytest.register_assert_rewrite("tests.common")
|
||||
|
||||
|
@ -332,7 +332,7 @@ def aiohttp_client_cls():
|
|||
@pytest.fixture
|
||||
def aiohttp_client(
|
||||
event_loop: asyncio.AbstractEventLoop,
|
||||
) -> Generator[TestClientGenerator, None, None]:
|
||||
) -> Generator[ClientSessionGenerator, None, None]:
|
||||
"""Override the default aiohttp_client since 3.x does not support aiohttp_client_cls.
|
||||
|
||||
Remove this when upgrading to 4.x as aiohttp_client_cls
|
||||
|
@ -609,10 +609,10 @@ def local_auth(hass):
|
|||
@pytest.fixture
|
||||
def hass_client(
|
||||
hass: HomeAssistant,
|
||||
aiohttp_client: TestClientGenerator,
|
||||
aiohttp_client: ClientSessionGenerator,
|
||||
hass_access_token: str,
|
||||
socket_enabled: None,
|
||||
) -> TestClientGenerator:
|
||||
) -> ClientSessionGenerator:
|
||||
"""Return an authenticated HTTP client."""
|
||||
|
||||
async def auth_client() -> TestClient:
|
||||
|
@ -627,9 +627,9 @@ def hass_client(
|
|||
@pytest.fixture
|
||||
def hass_client_no_auth(
|
||||
hass: HomeAssistant,
|
||||
aiohttp_client: TestClientGenerator,
|
||||
aiohttp_client: ClientSessionGenerator,
|
||||
socket_enabled: None,
|
||||
) -> TestClientGenerator:
|
||||
) -> ClientSessionGenerator:
|
||||
"""Return an unauthenticated HTTP client."""
|
||||
|
||||
async def client() -> TestClient:
|
||||
|
@ -665,11 +665,11 @@ def current_request_with_host(current_request):
|
|||
|
||||
@pytest.fixture
|
||||
def hass_ws_client(
|
||||
aiohttp_client: TestClientGenerator,
|
||||
aiohttp_client: ClientSessionGenerator,
|
||||
hass_access_token: str | None,
|
||||
hass: HomeAssistant,
|
||||
socket_enabled: None,
|
||||
) -> TestWebSocketGenerator:
|
||||
) -> WebSocketGenerator:
|
||||
"""Websocket client fixture connected to websocket server."""
|
||||
|
||||
async def create_client(
|
||||
|
|
|
@ -7,5 +7,5 @@ from typing import Any
|
|||
from aiohttp import ClientWebSocketResponse
|
||||
from aiohttp.test_utils import TestClient
|
||||
|
||||
TestClientGenerator = Callable[..., Coroutine[Any, Any, TestClient]]
|
||||
TestWebSocketGenerator = Callable[..., Coroutine[Any, Any, ClientWebSocketResponse]]
|
||||
ClientSessionGenerator = Callable[..., Coroutine[Any, Any, TestClient]]
|
||||
WebSocketGenerator = Callable[..., Coroutine[Any, Any, ClientWebSocketResponse]]
|
||||
|
|
Loading…
Reference in New Issue