Skip to content

Commit

Permalink
Fix issues in backup model (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 authored Nov 21, 2024
1 parent 207f13e commit 622970c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions aiohasupervisor/models/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BackupContent(ResponseData):

homeassistant: bool
addons: list[str]
folders: list[str]
folders: list[Folder]


@dataclass(frozen=True)
Expand Down Expand Up @@ -73,11 +73,11 @@ class BackupAddon(ResponseData):
class BackupComplete(BackupBaseFields, ResponseData):
"""BackupComplete model."""

supervisor_version: str
supervisor_version: str | None
homeassistant: str
addons: list[BackupAddon]
repositories: list[str]
folders: list[str]
folders: list[Folder]
homeassistant_exclude_database: bool | None


Expand Down
32 changes: 32 additions & 0 deletions tests/fixtures/backup_info_no_homeassistant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"result": "ok",
"data": {
"slug": "d13dedd0",
"type": "partial",
"name": "Studio Code Server",
"date": "2023-08-10T19:37:01.084215+00:00",
"size": 0.12,
"compressed": true,
"protected": false,
"supervisor_version": "2023.08.2.dev1002",
"homeassistant": null,
"location": "Test",
"addons": [
{
"slug": "a0d7b954_vscode",
"name": "Studio Code Server",
"version": "5.6.1",
"size": 0.1
}
],
"repositories": [
"local",
"https://github.com/hassio-addons/repository",
"core",
"https://github.com/music-assistant/home-assistant-addon",
"https://github.com/esphome/home-assistant-addon"
],
"folders": [],
"homeassistant_exclude_database": null
}
}
15 changes: 15 additions & 0 deletions tests/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,21 @@ async def test_backup_info(
assert result.homeassistant_exclude_database is None


async def test_backup_info_no_homeassistant(
responses: aioresponses, supervisor_client: SupervisorClient
) -> None:
"""Test backup info API with no home assistant."""
responses.get(
f"{SUPERVISOR_URL}/backups/d13dedd0/info",
status=200,
body=load_fixture("backup_info_no_homeassistant.json"),
)
result = await supervisor_client.backups.backup_info("d13dedd0")
assert result.slug == "d13dedd0"
assert result.type == "partial"
assert result.homeassistant is None


async def test_remove_backup(
responses: aioresponses, supervisor_client: SupervisorClient
) -> None:
Expand Down

0 comments on commit 622970c

Please sign in to comment.