mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Add type hints for Recorder in test fixtures (#118685)
This commit is contained in:
parent
666fc2333a
commit
8772a59f5c
@ -5,6 +5,8 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.energy import async_get_manager, validate
|
||||
from homeassistant.components.energy.data import EnergyManager
|
||||
from homeassistant.components.recorder import Recorder
|
||||
from homeassistant.const import UnitOfEnergy
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.json import JSON_DUMP
|
||||
@ -46,7 +48,9 @@ def mock_get_metadata():
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def mock_energy_manager(recorder_mock, hass):
|
||||
async def mock_energy_manager(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> EnergyManager:
|
||||
"""Set up energy."""
|
||||
assert await async_setup_component(hass, "energy", {"energy": {}})
|
||||
manager = await async_get_manager(hass)
|
||||
|
@ -21,13 +21,13 @@ from tests.typing import WebSocketGenerator
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def setup_integration(recorder_mock, hass):
|
||||
async def setup_integration(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Set up the integration."""
|
||||
assert await async_setup_component(hass, "energy", {})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_energy_platform(hass):
|
||||
def mock_energy_platform(hass: HomeAssistant) -> None:
|
||||
"""Mock an energy platform."""
|
||||
hass.config.components.add("some_domain")
|
||||
mock_platform(
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""The tests for the recorder filter matching the EntityFilter component."""
|
||||
|
||||
from collections.abc import AsyncGenerator
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
@ -38,7 +39,9 @@ def db_schema_32():
|
||||
|
||||
|
||||
@pytest.fixture(name="legacy_recorder_mock")
|
||||
async def legacy_recorder_mock_fixture(recorder_mock):
|
||||
async def legacy_recorder_mock_fixture(
|
||||
recorder_mock: Recorder,
|
||||
) -> AsyncGenerator[Recorder, None]:
|
||||
"""Fixture for legacy recorder mock."""
|
||||
with patch.object(recorder_mock.states_meta_manager, "active", False):
|
||||
yield recorder_mock
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""The tests for the recorder filter matching the EntityFilter component."""
|
||||
|
||||
from collections.abc import AsyncGenerator
|
||||
import datetime
|
||||
import importlib
|
||||
import sys
|
||||
@ -14,7 +15,13 @@ from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from homeassistant.components import recorder
|
||||
from homeassistant.components.recorder import core, db_schema, migration, statistics
|
||||
from homeassistant.components.recorder import (
|
||||
Recorder,
|
||||
core,
|
||||
db_schema,
|
||||
migration,
|
||||
statistics,
|
||||
)
|
||||
from homeassistant.components.recorder.db_schema import (
|
||||
Events,
|
||||
EventTypes,
|
||||
@ -110,7 +117,9 @@ def db_schema_32():
|
||||
|
||||
|
||||
@pytest.fixture(name="legacy_recorder_mock")
|
||||
async def legacy_recorder_mock_fixture(recorder_mock):
|
||||
async def legacy_recorder_mock_fixture(
|
||||
recorder_mock: Recorder,
|
||||
) -> AsyncGenerator[Recorder, None]:
|
||||
"""Fixture for legacy recorder mock."""
|
||||
with patch.object(recorder_mock.states_meta_manager, "active", False):
|
||||
yield recorder_mock
|
||||
|
Loading…
x
Reference in New Issue
Block a user