mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 23:07:09 +00:00
Add type hints for hass_storage in test fixtures (#118682)
This commit is contained in:
parent
fdec1b0b16
commit
f39dd40be1
@ -1,6 +1,7 @@
|
|||||||
"""Test configuration and mocks for the SmartThings component."""
|
"""Test configuration and mocks for the SmartThings component."""
|
||||||
|
|
||||||
import secrets
|
import secrets
|
||||||
|
from typing import Any
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ from homeassistant.const import (
|
|||||||
CONF_CLIENT_SECRET,
|
CONF_CLIENT_SECRET,
|
||||||
CONF_WEBHOOK_ID,
|
CONF_WEBHOOK_ID,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
@ -74,7 +76,9 @@ async def setup_platform(hass, platform: str, *, devices=None, scenes=None):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
async def setup_component(hass, config_file, hass_storage):
|
async def setup_component(
|
||||||
|
hass: HomeAssistant, config_file: dict[str, str], hass_storage: dict[str, Any]
|
||||||
|
) -> None:
|
||||||
"""Load the SmartThing component."""
|
"""Load the SmartThing component."""
|
||||||
hass_storage[STORAGE_KEY] = {"data": config_file, "version": STORAGE_VERSION}
|
hass_storage[STORAGE_KEY] = {"data": config_file, "version": STORAGE_VERSION}
|
||||||
await async_process_ha_core_config(
|
await async_process_ha_core_config(
|
||||||
@ -166,7 +170,7 @@ def installed_apps_fixture(installed_app, locations, app):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="config_file")
|
@pytest.fixture(name="config_file")
|
||||||
def config_file_fixture():
|
def config_file_fixture() -> dict[str, str]:
|
||||||
"""Fixture representing the local config file contents."""
|
"""Fixture representing the local config file contents."""
|
||||||
return {CONF_INSTANCE_ID: str(uuid4()), CONF_WEBHOOK_ID: secrets.token_hex()}
|
return {CONF_INSTANCE_ID: str(uuid4()), CONF_WEBHOOK_ID: secrets.token_hex()}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def storage_setup(hass: HomeAssistant, hass_storage: dict[str, Any]):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def storage_setup_1_1(hass: HomeAssistant, hass_storage):
|
def storage_setup_1_1(hass: HomeAssistant, hass_storage: dict[str, Any]):
|
||||||
"""Storage version 1.1 setup."""
|
"""Storage version 1.1 setup."""
|
||||||
|
|
||||||
async def _storage(items=None):
|
async def _storage(items=None):
|
||||||
@ -87,7 +87,7 @@ async def test_migration(
|
|||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
storage_setup_1_1,
|
storage_setup_1_1,
|
||||||
freezer: FrozenDateTimeFactory,
|
freezer: FrozenDateTimeFactory,
|
||||||
hass_storage,
|
hass_storage: dict[str, Any],
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test migrating tag store."""
|
"""Test migrating tag store."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user