Improve type hints in tile tests (#123916)
This commit is contained in:
parent
1e5762fbf7
commit
78c868c075
1 changed files with 12 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
|||
"""Define test fixtures for Tile."""
|
||||
|
||||
from collections.abc import Generator
|
||||
import json
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
@ -8,6 +10,7 @@ from pytile.tile import Tile
|
|||
|
||||
from homeassistant.components.tile.const import DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
|
||||
|
@ -16,7 +19,7 @@ TEST_USERNAME = "user@host.com"
|
|||
|
||||
|
||||
@pytest.fixture(name="api")
|
||||
def api_fixture(hass, data_tile_details):
|
||||
def api_fixture(data_tile_details: dict[str, Any]) -> Mock:
|
||||
"""Define a pytile API object."""
|
||||
tile = Tile(None, data_tile_details)
|
||||
tile.async_update = AsyncMock()
|
||||
|
@ -29,7 +32,9 @@ def api_fixture(hass, data_tile_details):
|
|||
|
||||
|
||||
@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, unique_id=config[CONF_USERNAME], data=config)
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -37,7 +42,7 @@ def config_entry_fixture(hass, config):
|
|||
|
||||
|
||||
@pytest.fixture(name="config")
|
||||
def config_fixture():
|
||||
def config_fixture() -> dict[str, Any]:
|
||||
"""Define a config entry data fixture."""
|
||||
return {
|
||||
CONF_USERNAME: TEST_USERNAME,
|
||||
|
@ -52,7 +57,7 @@ def data_tile_details_fixture():
|
|||
|
||||
|
||||
@pytest.fixture(name="mock_pytile")
|
||||
async def mock_pytile_fixture(api):
|
||||
def mock_pytile_fixture(api: Mock) -> Generator[None]:
|
||||
"""Define a fixture to patch pytile."""
|
||||
with (
|
||||
patch(
|
||||
|
@ -64,7 +69,9 @@ async def mock_pytile_fixture(api):
|
|||
|
||||
|
||||
@pytest.fixture(name="setup_config_entry")
|
||||
async def setup_config_entry_fixture(hass, config_entry, mock_pytile):
|
||||
async def setup_config_entry_fixture(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, mock_pytile: None
|
||||
) -> None:
|
||||
"""Define a fixture to set up tile."""
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Add table
Reference in a new issue