Adjust recorder backup platform tests (#139492)

pull/136509/head^2
Erik Montnemery 2025-02-28 11:44:58 +01:00 committed by GitHub
parent 1be9836663
commit 5cf56ec113
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 4 deletions

View File

@ -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