Avoid time traveling in recorder tests (#80247)
This commit is contained in:
parent
4462f2fc46
commit
acb1477673
1 changed files with 3 additions and 8 deletions
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
import time
|
||||
from typing import Any, cast
|
||||
|
||||
|
@ -21,8 +21,6 @@ from homeassistant.util import dt as dt_util
|
|||
|
||||
from . import db_schema_0
|
||||
|
||||
from tests.common import async_fire_time_changed, fire_time_changed
|
||||
|
||||
DEFAULT_PURGE_TASKS = 3
|
||||
|
||||
|
||||
|
@ -69,9 +67,7 @@ def wait_recording_done(hass: HomeAssistant) -> None:
|
|||
|
||||
def trigger_db_commit(hass: HomeAssistant) -> None:
|
||||
"""Force the recorder to commit."""
|
||||
for _ in range(recorder.DEFAULT_COMMIT_INTERVAL):
|
||||
# We only commit on time change
|
||||
fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=1))
|
||||
recorder.get_instance(hass)._async_commit(dt_util.utcnow())
|
||||
|
||||
|
||||
async def async_wait_recording_done(hass: HomeAssistant) -> None:
|
||||
|
@ -100,8 +96,7 @@ async def async_wait_purge_done(hass: HomeAssistant, max: int = None) -> None:
|
|||
@ha.callback
|
||||
def async_trigger_db_commit(hass: HomeAssistant) -> None:
|
||||
"""Force the recorder to commit. Async friendly."""
|
||||
for _ in range(recorder.DEFAULT_COMMIT_INTERVAL):
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=1))
|
||||
recorder.get_instance(hass)._async_commit(dt_util.utcnow())
|
||||
|
||||
|
||||
async def async_recorder_block_till_done(hass: HomeAssistant) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue