Don't compile missing statistics when running tests (#99446)

This commit is contained in:
Erik Montnemery 2023-09-02 17:09:46 +02:00 committed by GitHub
parent 7168e71860
commit defd9e4001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1276,6 +1276,11 @@ def hass_recorder(
hass = get_test_home_assistant()
nightly = recorder.Recorder.async_nightly_tasks if enable_nightly_purge else None
stats = recorder.Recorder.async_periodic_statistics if enable_statistics else None
compile_missing = (
recorder.Recorder._schedule_compile_missing_statistics
if enable_statistics
else None
)
schema_validate = (
migration._find_schema_errors
if enable_schema_validation
@ -1327,6 +1332,10 @@ def hass_recorder(
"homeassistant.components.recorder.Recorder._migrate_entity_ids",
side_effect=migrate_entity_ids,
autospec=True,
), patch(
"homeassistant.components.recorder.Recorder._schedule_compile_missing_statistics",
side_effect=compile_missing,
autospec=True,
):
def setup_recorder(config: dict[str, Any] | None = None) -> HomeAssistant:
@ -1399,6 +1408,11 @@ async def async_setup_recorder_instance(
if enable_schema_validation
else itertools.repeat(set())
)
compile_missing = (
recorder.Recorder._schedule_compile_missing_statistics
if enable_statistics
else None
)
migrate_states_context_ids = (
recorder.Recorder._migrate_states_context_ids
if enable_migrate_context_ids
@ -1445,6 +1459,10 @@ async def async_setup_recorder_instance(
"homeassistant.components.recorder.Recorder._migrate_entity_ids",
side_effect=migrate_entity_ids,
autospec=True,
), patch(
"homeassistant.components.recorder.Recorder._schedule_compile_missing_statistics",
side_effect=compile_missing,
autospec=True,
):
async def async_setup_recorder(