Add type hints for ClientSessionGenerator in test fixtures (#118689)

This commit is contained in:
epenet 2024-06-03 10:19:49 +02:00 committed by GitHub
parent 77c627e6f3
commit fdec1b0b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 7 deletions

View File

@ -18,6 +18,9 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.test_util.aiohttp import AiohttpClientMocker
from tests.typing import ClientSessionGenerator
CLIENT_ID = "1234" CLIENT_ID = "1234"
CLIENT_SECRET = "5678" CLIENT_SECRET = "5678"
@ -33,12 +36,11 @@ async def setup_credentials(hass: HomeAssistant) -> None:
) )
@pytest.mark.usefixtures("current_request_with_host", "setup_credentials")
async def test_full_flow( async def test_full_flow(
hass: HomeAssistant, hass: HomeAssistant,
hass_client_no_auth, hass_client_no_auth: ClientSessionGenerator,
aioclient_mock, aioclient_mock: AiohttpClientMocker,
current_request_with_host,
setup_credentials,
) -> None: ) -> None:
"""Check full flow.""" """Check full flow."""
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(

View File

@ -7,7 +7,6 @@ from typing import Any
import urllib import urllib
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
from aiohttp import ClientSession
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import pytest import pytest
@ -115,7 +114,7 @@ def mock_insert_schedule_response(
@pytest.fixture(name="get_events") @pytest.fixture(name="get_events")
def get_events_fixture( def get_events_fixture(
hass_client: Callable[..., Awaitable[ClientSession]], hass_client: ClientSessionGenerator,
) -> GetEventsFn: ) -> GetEventsFn:
"""Fetch calendar events from the HTTP API.""" """Fetch calendar events from the HTTP API."""

View File

@ -3,6 +3,7 @@
from http import HTTPStatus from http import HTTPStatus
from unittest.mock import patch from unittest.mock import patch
from aiohttp.test_utils import TestClient
import pytest import pytest
from homeassistant import config_entries from homeassistant import config_entries
@ -17,6 +18,8 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.dispatcher import DATA_DISPATCHER from homeassistant.helpers.dispatcher import DATA_DISPATCHER
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.typing import ClientSessionGenerator
HOME_LATITUDE = 37.239622 HOME_LATITUDE = 37.239622
HOME_LONGITUDE = -115.815811 HOME_LONGITUDE = -115.815811
@ -27,7 +30,9 @@ def mock_dev_track(mock_device_tracker_conf):
@pytest.fixture(name="client") @pytest.fixture(name="client")
async def traccar_client(hass, hass_client_no_auth): async def traccar_client(
hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator
) -> TestClient:
"""Mock client for Traccar (unauthenticated).""" """Mock client for Traccar (unauthenticated)."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})