mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Adjust recorder backup platform tests (#139492)
This commit is contained in:
parent
1be9836663
commit
5cf56ec113
@ -17,7 +17,7 @@ async def test_async_pre_backup(recorder_mock: Recorder, hass: HomeAssistant) ->
|
|||||||
"homeassistant.components.recorder.core.Recorder.lock_database"
|
"homeassistant.components.recorder.core.Recorder.lock_database"
|
||||||
) as lock_mock:
|
) as lock_mock:
|
||||||
await async_pre_backup(hass)
|
await async_pre_backup(hass)
|
||||||
assert lock_mock.called
|
assert lock_mock.called
|
||||||
|
|
||||||
|
|
||||||
RAISES_HASS_NOT_RUNNING = pytest.raises(
|
RAISES_HASS_NOT_RUNNING = pytest.raises(
|
||||||
@ -75,13 +75,17 @@ async def test_async_pre_backup_with_migration(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test pre backup with migration."""
|
"""Test pre backup with migration."""
|
||||||
with (
|
with (
|
||||||
|
patch(
|
||||||
|
"homeassistant.components.recorder.core.Recorder.lock_database"
|
||||||
|
) as lock_mock,
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.recorder.backup.async_migration_in_progress",
|
"homeassistant.components.recorder.backup.async_migration_in_progress",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
),
|
),
|
||||||
pytest.raises(HomeAssistantError),
|
pytest.raises(HomeAssistantError, match="Database migration in progress"),
|
||||||
):
|
):
|
||||||
await async_pre_backup(hass)
|
await async_pre_backup(hass)
|
||||||
|
assert not lock_mock.called
|
||||||
|
|
||||||
|
|
||||||
async def test_async_post_backup(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_async_post_backup(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
@ -90,7 +94,7 @@ async def test_async_post_backup(recorder_mock: Recorder, hass: HomeAssistant) -
|
|||||||
"homeassistant.components.recorder.core.Recorder.unlock_database"
|
"homeassistant.components.recorder.core.Recorder.unlock_database"
|
||||||
) as unlock_mock:
|
) as unlock_mock:
|
||||||
await async_post_backup(hass)
|
await async_post_backup(hass)
|
||||||
assert unlock_mock.called
|
assert unlock_mock.called
|
||||||
|
|
||||||
|
|
||||||
async def test_async_post_backup_failure(
|
async def test_async_post_backup_failure(
|
||||||
@ -102,7 +106,9 @@ async def test_async_post_backup_failure(
|
|||||||
"homeassistant.components.recorder.core.Recorder.unlock_database",
|
"homeassistant.components.recorder.core.Recorder.unlock_database",
|
||||||
return_value=False,
|
return_value=False,
|
||||||
) as unlock_mock,
|
) as unlock_mock,
|
||||||
pytest.raises(HomeAssistantError),
|
pytest.raises(
|
||||||
|
HomeAssistantError, match="Could not release database write lock"
|
||||||
|
),
|
||||||
):
|
):
|
||||||
await async_post_backup(hass)
|
await async_post_backup(hass)
|
||||||
assert unlock_mock.called
|
assert unlock_mock.called
|
||||||
|
Loading…
x
Reference in New Issue
Block a user