Adjust recorder backup platform tests (#139492)
parent
1be9836663
commit
5cf56ec113
|
@ -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:
|
||||||
|
@ -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…
Reference in New Issue