mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Disable recorder nightly jobs in tests (#68188)
This commit is contained in:
parent
34eb4aa2d0
commit
d360ac91ca
@ -600,6 +600,7 @@ def run_tasks_at_time(hass, test_time):
|
|||||||
hass.data[DATA_INSTANCE].block_till_done()
|
hass.data[DATA_INSTANCE].block_till_done()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("enable_nightly_purge", [True])
|
||||||
def test_auto_purge(hass_recorder):
|
def test_auto_purge(hass_recorder):
|
||||||
"""Test periodic purge scheduling."""
|
"""Test periodic purge scheduling."""
|
||||||
hass = hass_recorder()
|
hass = hass_recorder()
|
||||||
@ -657,6 +658,7 @@ def test_auto_purge(hass_recorder):
|
|||||||
dt_util.set_default_time_zone(original_tz)
|
dt_util.set_default_time_zone(original_tz)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("enable_nightly_purge", [True])
|
||||||
def test_auto_purge_disabled(hass_recorder):
|
def test_auto_purge_disabled(hass_recorder):
|
||||||
"""Test periodic db cleanup still run when auto purge is disabled."""
|
"""Test periodic db cleanup still run when auto purge is disabled."""
|
||||||
hass = hass_recorder({CONF_AUTO_PURGE: False})
|
hass = hass_recorder({CONF_AUTO_PURGE: False})
|
||||||
|
@ -778,14 +778,29 @@ def enable_statistics():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def hass_recorder(enable_statistics, hass_storage):
|
def enable_nightly_purge():
|
||||||
|
"""Fixture to control enabling of recorder's nightly purge job.
|
||||||
|
|
||||||
|
To enable nightly purgin, tests can be marked with:
|
||||||
|
@pytest.mark.parametrize("enable_nightly_purge", [True])
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def hass_recorder(enable_nightly_purge, enable_statistics, hass_storage):
|
||||||
"""Home Assistant fixture with in-memory recorder."""
|
"""Home Assistant fixture with in-memory recorder."""
|
||||||
hass = get_test_home_assistant()
|
hass = get_test_home_assistant()
|
||||||
stats = recorder.Recorder.async_periodic_statistics if enable_statistics else None
|
stats = recorder.Recorder.async_periodic_statistics if enable_statistics else None
|
||||||
|
nightly = recorder.Recorder.async_nightly_tasks if enable_nightly_purge else None
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.recorder.Recorder.async_periodic_statistics",
|
"homeassistant.components.recorder.Recorder.async_periodic_statistics",
|
||||||
side_effect=stats,
|
side_effect=stats,
|
||||||
autospec=True,
|
autospec=True,
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.recorder.Recorder.async_nightly_tasks",
|
||||||
|
side_effect=nightly,
|
||||||
|
autospec=True,
|
||||||
):
|
):
|
||||||
|
|
||||||
def setup_recorder(config=None):
|
def setup_recorder(config=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user