Skip to content

Commit 1ec0ce1

Browse files
committed
Add protected locations field to backup model
1 parent 51a8a78 commit 1ec0ce1

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

aiohasupervisor/models/backups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class BackupBaseFields(ABC):
5757
location: str | None
5858
locations: set[str | None]
5959
protected: bool
60+
protected_locations: set[str | None]
6061
compressed: bool
6162

6263

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"result": "ok",
3+
"data": {
4+
"slug": "d9c48f8b",
5+
"type": "partial",
6+
"name": "test_consolidate",
7+
"date": "2025-01-22T18:09:28.196333+00:00",
8+
"size": 0.01,
9+
"size_bytes": 10240,
10+
"compressed": true,
11+
"protected": true,
12+
"protected_locations": [null, "test"],
13+
"supervisor_version": "2025.01.1.dev2104",
14+
"homeassistant": null,
15+
"location": null,
16+
"locations": [null, "test"],
17+
"addons": [],
18+
"repositories": [
19+
"https://github.com/esphome/home-assistant-addon",
20+
"https://github.com/hassio-addons/repository",
21+
"https://github.com/music-assistant/home-assistant-addon",
22+
"local",
23+
"core"
24+
],
25+
"folders": ["ssl"],
26+
"homeassistant_exclude_database": null,
27+
"extra": {}
28+
}
29+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"result": "ok",
3+
"data": {
4+
"backups": [
5+
{
6+
"slug": "d9c48f8b",
7+
"name": "test_consolidate",
8+
"date": "2025-01-22T18:09:28.196333+00:00",
9+
"type": "partial",
10+
"size": 0.01,
11+
"size_bytes": 10240,
12+
"location": null,
13+
"locations": [null, "test"],
14+
"protected": true,
15+
"protected_locations": [null, "test"],
16+
"compressed": true,
17+
"content": {
18+
"homeassistant": false,
19+
"addons": [],
20+
"folders": ["ssl"]
21+
}
22+
}
23+
]
24+
}
25+
}

tests/test_backups.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,3 +555,33 @@ async def test_full_backup_model(
555555
"""Test full backup model parsing and serializing."""
556556
assert FullBackupOptions.from_dict(as_dict) == options
557557
assert options.to_dict() == as_dict
558+
559+
560+
async def test_backups_list_protected_locations(
561+
responses: aioresponses,
562+
supervisor_client: SupervisorClient,
563+
) -> None:
564+
"""Test protected locations field in backups list."""
565+
responses.get(
566+
f"{SUPERVISOR_URL}/backups",
567+
status=200,
568+
body=load_fixture("backups_list_protected_locations.json"),
569+
)
570+
571+
result = await supervisor_client.backups.list()
572+
assert result[0].protected_locations == {None, "test"}
573+
574+
575+
async def test_backup_info_protected_locations(
576+
responses: aioresponses,
577+
supervisor_client: SupervisorClient,
578+
) -> None:
579+
"""Test protected locations field in backup info."""
580+
responses.get(
581+
f"{SUPERVISOR_URL}/backups/d9c48f8b/info",
582+
status=200,
583+
body=load_fixture("backup_info_protected_locations.json"),
584+
)
585+
586+
result = await supervisor_client.backups.backup_info("d9c48f8b")
587+
assert result.protected_locations == {None, "test"}

0 commit comments

Comments
 (0)