1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Remove hass_recorder test fixture (#120295)

This commit is contained in:
Erik Montnemery
2024-06-24 11:14:08 +02:00
committed by GitHub
parent be6dfc7a70
commit e32a27a8ff
3 changed files with 0 additions and 143 deletions

View File

@@ -70,7 +70,6 @@ from homeassistant.helpers import (
intent,
issue_registry as ir,
label_registry as lr,
recorder as recorder_helper,
restore_state as rs,
storage,
translation,
@@ -83,7 +82,6 @@ from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.json import JSONEncoder, _orjson_default_encoder, json_dumps
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.setup import setup_component
from homeassistant.util.async_ import run_callback_threadsafe
import homeassistant.util.dt as dt_util
from homeassistant.util.json import (
@@ -1162,30 +1160,6 @@ def assert_setup_component(count, domain=None):
), f"setup_component failed, expected {count} got {res_len}: {res}"
def init_recorder_component(hass, add_config=None, db_url="sqlite://"):
"""Initialize the recorder."""
# Local import to avoid processing recorder and SQLite modules when running a
# testcase which does not use the recorder.
# pylint: disable-next=import-outside-toplevel
from homeassistant.components import recorder
config = dict(add_config) if add_config else {}
if recorder.CONF_DB_URL not in config:
config[recorder.CONF_DB_URL] = db_url
if recorder.CONF_COMMIT_INTERVAL not in config:
config[recorder.CONF_COMMIT_INTERVAL] = 0
with patch("homeassistant.components.recorder.ALLOW_IN_MEMORY_DB", True):
if recorder.DOMAIN not in hass.data:
recorder_helper.async_initialize_recorder(hass)
assert setup_component(hass, recorder.DOMAIN, {recorder.DOMAIN: config})
assert recorder.DOMAIN in hass.config.components
_LOGGER.info(
"Test recorder successfully started, database location: %s",
config[recorder.CONF_DB_URL],
)
def mock_restore_cache(hass: HomeAssistant, states: Sequence[State]) -> None:
"""Mock the DATA_RESTORE_CACHE."""
key = rs.DATA_RESTORE_STATE