Improve type hints in ridwell tests (#123886)

pull/123907/head
epenet 2024-08-14 12:50:51 +02:00 committed by GitHub
parent 13b071fd72
commit 7fe2f175aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 6 deletions

View File

@ -1,6 +1,8 @@
"""Define test fixtures for Ridwell."""
from collections.abc import Generator
from datetime import date
from typing import Any
from unittest.mock import AsyncMock, Mock, patch
from aioridwell.model import EventState, RidwellPickup, RidwellPickupEvent
@ -8,6 +10,7 @@ import pytest
from homeassistant.components.ridwell.const import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@ -19,7 +22,7 @@ TEST_USER_ID = "12345"
@pytest.fixture(name="account")
def account_fixture():
def account_fixture() -> Mock:
"""Define a Ridwell account."""
return Mock(
account_id=TEST_ACCOUNT_ID,
@ -44,7 +47,7 @@ def account_fixture():
@pytest.fixture(name="client")
def client_fixture(account):
def client_fixture(account: Mock) -> Mock:
"""Define an aioridwell client."""
return Mock(
async_authenticate=AsyncMock(),
@ -55,7 +58,9 @@ def client_fixture(account):
@pytest.fixture(name="config_entry")
def config_entry_fixture(hass, config):
def config_entry_fixture(
hass: HomeAssistant, config: dict[str, Any]
) -> MockConfigEntry:
"""Define a config entry fixture."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -68,7 +73,7 @@ def config_entry_fixture(hass, config):
@pytest.fixture(name="config")
def config_fixture(hass):
def config_fixture() -> dict[str, Any]:
"""Define a config entry data fixture."""
return {
CONF_USERNAME: TEST_USERNAME,
@ -77,7 +82,7 @@ def config_fixture(hass):
@pytest.fixture(name="mock_aioridwell")
async def mock_aioridwell_fixture(hass, client, config):
def mock_aioridwell_fixture(client: Mock, config: dict[str, Any]) -> Generator[None]:
"""Define a fixture to patch aioridwell."""
with (
patch(
@ -93,7 +98,9 @@ async def mock_aioridwell_fixture(hass, client, config):
@pytest.fixture(name="setup_config_entry")
async def setup_config_entry_fixture(hass, config_entry, mock_aioridwell):
async def setup_config_entry_fixture(
hass: HomeAssistant, config_entry: MockConfigEntry, mock_aioridwell: None
) -> None:
"""Define a fixture to set up ridwell."""
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()