Skip to content

Commit 622970c

Browse files
authored
Fix issues in backup model (#30)
1 parent 207f13e commit 622970c

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

aiohasupervisor/models/backups.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BackupContent(ResponseData):
3535

3636
homeassistant: bool
3737
addons: list[str]
38-
folders: list[str]
38+
folders: list[Folder]
3939

4040

4141
@dataclass(frozen=True)
@@ -73,11 +73,11 @@ class BackupAddon(ResponseData):
7373
class BackupComplete(BackupBaseFields, ResponseData):
7474
"""BackupComplete model."""
7575

76-
supervisor_version: str
76+
supervisor_version: str | None
7777
homeassistant: str
7878
addons: list[BackupAddon]
7979
repositories: list[str]
80-
folders: list[str]
80+
folders: list[Folder]
8181
homeassistant_exclude_database: bool | None
8282

8383

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"result": "ok",
3+
"data": {
4+
"slug": "d13dedd0",
5+
"type": "partial",
6+
"name": "Studio Code Server",
7+
"date": "2023-08-10T19:37:01.084215+00:00",
8+
"size": 0.12,
9+
"compressed": true,
10+
"protected": false,
11+
"supervisor_version": "2023.08.2.dev1002",
12+
"homeassistant": null,
13+
"location": "Test",
14+
"addons": [
15+
{
16+
"slug": "a0d7b954_vscode",
17+
"name": "Studio Code Server",
18+
"version": "5.6.1",
19+
"size": 0.1
20+
}
21+
],
22+
"repositories": [
23+
"local",
24+
"https://github.com/hassio-addons/repository",
25+
"core",
26+
"https://github.com/music-assistant/home-assistant-addon",
27+
"https://github.com/esphome/home-assistant-addon"
28+
],
29+
"folders": [],
30+
"homeassistant_exclude_database": null
31+
}
32+
}

tests/test_backups.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,21 @@ async def test_backup_info(
213213
assert result.homeassistant_exclude_database is None
214214

215215

216+
async def test_backup_info_no_homeassistant(
217+
responses: aioresponses, supervisor_client: SupervisorClient
218+
) -> None:
219+
"""Test backup info API with no home assistant."""
220+
responses.get(
221+
f"{SUPERVISOR_URL}/backups/d13dedd0/info",
222+
status=200,
223+
body=load_fixture("backup_info_no_homeassistant.json"),
224+
)
225+
result = await supervisor_client.backups.backup_info("d13dedd0")
226+
assert result.slug == "d13dedd0"
227+
assert result.type == "partial"
228+
assert result.homeassistant is None
229+
230+
216231
async def test_remove_backup(
217232
responses: aioresponses, supervisor_client: SupervisorClient
218233
) -> None:

0 commit comments

Comments
 (0)