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
|
|
|
|
|
|
|
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,
|
|
|
|
):
|
2024-07-23 12:13:08 +00:00
|
|
|
assert recorder.async_migration_in_progress(hass) is True
|
2021-04-13 00:18:38 +00:00
|
|
|
|
|
|
|
|
2024-07-23 12:13:08 +00:00
|
|
|
async def test_async_migration_is_live(
|
|
|
|
async_setup_recorder_instance: RecorderInstanceGenerator, hass: HomeAssistant
|
|
|
|
) -> None:
|
|
|
|
"""Test async_migration_in_progress wraps the recorder."""
|
2021-04-13 00:18:38 +00:00
|
|
|
with patch(
|
2024-07-23 12:13:08 +00:00
|
|
|
"homeassistant.components.recorder.util.async_migration_is_live",
|
|
|
|
return_value=False,
|
|
|
|
):
|
|
|
|
assert recorder.async_migration_is_live(hass) is False
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
"homeassistant.components.recorder.util.async_migration_is_live",
|
2021-04-13 00:18:38 +00:00
|
|
|
return_value=True,
|
|
|
|
):
|
2024-07-23 12:13:08 +00:00
|
|
|
assert recorder.async_migration_is_live(hass) is True
|