2021-04-13 00:18:38 +00:00
|
|
|
"""The tests for the recorder helpers."""
|
|
|
|
|
|
|
|
from unittest.mock import patch
|
|
|
|
|
2022-04-25 12:23:52 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2021-04-13 00:18:38 +00:00
|
|
|
from homeassistant.helpers import recorder
|
|
|
|
|
2023-02-17 17:50:09 +00:00
|
|
|
from tests.typing import RecorderInstanceGenerator
|
2021-04-13 00:18:38 +00:00
|
|
|
|
|
|
|
|
2022-04-25 12:23:52 +00:00
|
|
|
async def test_async_migration_in_progress(
|
2023-02-17 17:50:09 +00:00
|
|
|
async_setup_recorder_instance: RecorderInstanceGenerator, hass: HomeAssistant
|
|
|
|
) -> None:
|
2021-04-13 00:18:38 +00:00
|
|
|
"""Test async_migration_in_progress wraps the recorder."""
|
|
|
|
with patch(
|
2021-11-05 09:40:56 +00:00
|
|
|
"homeassistant.components.recorder.util.async_migration_in_progress",
|
2021-04-13 00:18:38 +00:00
|
|
|
return_value=False,
|
|
|
|
):
|
2021-11-05 09:40:56 +00:00
|
|
|
assert recorder.async_migration_in_progress(hass) is False
|
2021-04-13 00:18:38 +00:00
|
|
|
|
|
|
|
# The recorder is not loaded
|
|
|
|
with patch(
|
2021-11-05 09:40:56 +00:00
|
|
|
"homeassistant.components.recorder.util.async_migration_in_progress",
|
2021-04-13 00:18:38 +00:00
|
|
|
return_value=True,
|
|
|
|
):
|
2021-11-05 09:40:56 +00:00
|
|
|
assert recorder.async_migration_in_progress(hass) is False
|
2021-04-13 00:18:38 +00:00
|
|
|
|
2022-04-25 12:23:52 +00:00
|
|
|
await async_setup_recorder_instance(hass)
|
2021-04-13 00:18:38 +00:00
|
|
|
|
|
|
|
# The recorder is now loaded
|
|
|
|
with patch(
|
2021-11-05 09:40:56 +00:00
|
|
|
"homeassistant.components.recorder.util.async_migration_in_progress",
|
2021-04-13 00:18:38 +00:00
|
|
|
return_value=True,
|
|
|
|
):
|
2021-11-05 09:40:56 +00:00
|
|
|
assert recorder.async_migration_in_progress(hass) is True
|