mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Always use a commit interval of 0 for the in memory db in tests (#69556)
This commit is contained in:
parent
5c7c09726a
commit
0ad9da9dd0
@ -1119,8 +1119,7 @@ class Recorder(threading.Thread):
|
|||||||
self.event_session.add(dbstate)
|
self.event_session.add(dbstate)
|
||||||
dbstate.event = dbevent
|
dbstate.event = dbevent
|
||||||
|
|
||||||
# If they do not have a commit interval
|
# Commit right away if the commit interval is zero
|
||||||
# than we commit right away
|
|
||||||
if not self.commit_interval:
|
if not self.commit_interval:
|
||||||
self._commit_event_session_or_retry()
|
self._commit_event_session_or_retry()
|
||||||
|
|
||||||
|
@ -905,7 +905,10 @@ def assert_setup_component(count, domain=None):
|
|||||||
def init_recorder_component(hass, add_config=None):
|
def init_recorder_component(hass, add_config=None):
|
||||||
"""Initialize the recorder."""
|
"""Initialize the recorder."""
|
||||||
config = dict(add_config) if add_config else {}
|
config = dict(add_config) if add_config else {}
|
||||||
|
if recorder.CONF_DB_URL not in config:
|
||||||
config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB
|
config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB
|
||||||
|
if recorder.CONF_COMMIT_INTERVAL not in config:
|
||||||
|
config[recorder.CONF_COMMIT_INTERVAL] = 0
|
||||||
|
|
||||||
with patch("homeassistant.components.recorder.migration.migrate_schema"):
|
with patch("homeassistant.components.recorder.migration.migrate_schema"):
|
||||||
assert setup_component(hass, recorder.DOMAIN, {recorder.DOMAIN: config})
|
assert setup_component(hass, recorder.DOMAIN, {recorder.DOMAIN: config})
|
||||||
@ -915,9 +918,11 @@ def init_recorder_component(hass, add_config=None):
|
|||||||
|
|
||||||
async def async_init_recorder_component(hass, add_config=None):
|
async def async_init_recorder_component(hass, add_config=None):
|
||||||
"""Initialize the recorder asynchronously."""
|
"""Initialize the recorder asynchronously."""
|
||||||
config = add_config or {recorder.CONF_COMMIT_INTERVAL: 0}
|
config = dict(add_config) if add_config else {}
|
||||||
if recorder.CONF_DB_URL not in config:
|
if recorder.CONF_DB_URL not in config:
|
||||||
config[recorder.CONF_DB_URL] = "sqlite://"
|
config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB
|
||||||
|
if recorder.CONF_COMMIT_INTERVAL not in config:
|
||||||
|
config[recorder.CONF_COMMIT_INTERVAL] = 0
|
||||||
|
|
||||||
with patch("homeassistant.components.recorder.migration.migrate_schema"):
|
with patch("homeassistant.components.recorder.migration.migrate_schema"):
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user