mirror of
https://github.com/home-assistant/core.git
synced 2026-11-06 05:32:45 -04:00
Fix hassio.backup_partial AttributeError when folders are specified (#170312)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
dc9eba372a
commit
6d8b010245
@@ -14,6 +14,7 @@ from aiohasupervisor.models import (
|
||||
AddonStage,
|
||||
AddonState,
|
||||
CIFSMountResponse,
|
||||
Folder,
|
||||
FullBackupOptions,
|
||||
HomeAssistantOptions,
|
||||
InstalledAddon,
|
||||
@@ -528,7 +529,7 @@ async def test_service_calls(
|
||||
name="2021-11-13 03:48:00",
|
||||
homeassistant=True,
|
||||
addons={"test"},
|
||||
folders={"ssl"},
|
||||
folders={Folder.SSL},
|
||||
password="123456",
|
||||
)
|
||||
)
|
||||
@@ -552,7 +553,10 @@ async def test_service_calls(
|
||||
supervisor_client.backups.partial_restore.assert_called_once_with(
|
||||
"test",
|
||||
PartialRestoreOptions(
|
||||
homeassistant=False, addons={"test"}, folders={"ssl"}, password="123456"
|
||||
homeassistant=False,
|
||||
addons={"test"},
|
||||
folders={Folder.SSL},
|
||||
password="123456",
|
||||
),
|
||||
)
|
||||
|
||||
@@ -770,6 +774,80 @@ async def test_invalid_service_calls_folder_duplicates(hass: HomeAssistant) -> N
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("hassio_env")
|
||||
async def test_partial_backup_legacy_homeassistant_folder(
|
||||
hass: HomeAssistant, supervisor_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test that the legacy "homeassistant" folder is translated to homeassistant=True."""
|
||||
assert await async_setup_component(hass, "hassio", {})
|
||||
supervisor_client.backups.partial_backup.return_value = NewBackup(
|
||||
job_id=uuid4(), slug="partial"
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
"hassio",
|
||||
"backup_partial",
|
||||
{"folders": ["homeassistant", "ssl"], "name": "test"},
|
||||
blocking=True,
|
||||
)
|
||||
supervisor_client.backups.partial_backup.assert_called_once_with(
|
||||
PartialBackupOptions(
|
||||
name="test",
|
||||
homeassistant=True,
|
||||
folders={Folder.SSL},
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("hassio_env")
|
||||
async def test_partial_restore_legacy_homeassistant_folder(
|
||||
hass: HomeAssistant, supervisor_client: AsyncMock
|
||||
) -> None:
|
||||
"""Test that the legacy "homeassistant" folder is translated for restore too."""
|
||||
assert await async_setup_component(hass, "hassio", {})
|
||||
|
||||
await hass.services.async_call(
|
||||
"hassio",
|
||||
"restore_partial",
|
||||
{"slug": "test", "folders": ["homeassistant", "ssl"]},
|
||||
blocking=True,
|
||||
)
|
||||
supervisor_client.backups.partial_restore.assert_called_once_with(
|
||||
"test",
|
||||
PartialRestoreOptions(
|
||||
homeassistant=True,
|
||||
folders={Folder.SSL},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("hassio_env", "supervisor_client")
|
||||
async def test_partial_backup_invalid_folder(hass: HomeAssistant) -> None:
|
||||
"""Test that an unknown folder name is rejected."""
|
||||
assert await async_setup_component(hass, "hassio", {})
|
||||
|
||||
with pytest.raises(Invalid, match="not a valid value"):
|
||||
await hass.services.async_call(
|
||||
"hassio", "backup_partial", {"folders": ["bogus"]}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("hassio_env", "supervisor_client")
|
||||
async def test_partial_backup_legacy_homeassistant_folder_conflict(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Reject combining homeassistant=False with the legacy "homeassistant" folder."""
|
||||
assert await async_setup_component(hass, "hassio", {})
|
||||
|
||||
with pytest.raises(ServiceValidationError, match="conflicts"):
|
||||
await hass.services.async_call(
|
||||
"hassio",
|
||||
"backup_partial",
|
||||
{"homeassistant": False, "folders": ["homeassistant"]},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("addon_installed")
|
||||
async def test_entry_load_and_unload(hass: HomeAssistant) -> None:
|
||||
"""Test loading and unloading config entry."""
|
||||
|
||||
Reference in New Issue
Block a user