Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aiohasupervisor/models/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class BackupBaseFields(ABC):
location: str | None
locations: set[str | None]
protected: bool
protected_locations: set[str | None]
compressed: bool


Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/backup_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"size_bytes": 10123,
"compressed": true,
"protected": false,
"protected_locations": [],
"supervisor_version": "2024.05.0",
"homeassistant": null,
"location": null,
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/backup_info_no_homeassistant.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"size_bytes": 120123,
"compressed": true,
"protected": false,
"protected_locations": [],
"supervisor_version": "2023.08.2.dev1002",
"homeassistant": null,
"location": "Test",
Expand Down
29 changes: 29 additions & 0 deletions tests/fixtures/backup_info_protected_locations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"result": "ok",
"data": {
"slug": "d9c48f8b",
"type": "partial",
"name": "test_consolidate",
"date": "2025-01-22T18:09:28.196333+00:00",
"size": 0.01,
"size_bytes": 10240,
"compressed": true,
"protected": true,
"protected_locations": [null, "test"],
"supervisor_version": "2025.01.1.dev2104",
"homeassistant": null,
"location": null,
"locations": [null, "test"],
"addons": [],
"repositories": [
"https://github.com/esphome/home-assistant-addon",
"https://github.com/hassio-addons/repository",
"https://github.com/music-assistant/home-assistant-addon",
"local",
"core"
],
"folders": ["ssl"],
"homeassistant_exclude_database": null,
"extra": {}
}
}
1 change: 1 addition & 0 deletions tests/fixtures/backup_info_with_extra.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"size_bytes": 10123,
"compressed": true,
"protected": false,
"protected_locations": [],
"supervisor_version": "2024.05.0",
"homeassistant": null,
"location": null,
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/backup_info_with_locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"size_bytes": 10123,
"compressed": true,
"protected": false,
"protected_locations": [],
"supervisor_version": "2024.05.0",
"homeassistant": null,
"location": null,
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/backups_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"location": null,
"locations": [null],
"protected": false,
"protected_locations": [],
"compressed": true,
"content": {
"homeassistant": true,
Expand All @@ -38,6 +39,7 @@
"location": null,
"locations": [null],
"protected": false,
"protected_locations": [],
"compressed": true,
"content": {
"homeassistant": false,
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/backups_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"location": null,
"locations": [null],
"protected": false,
"protected_locations": [],
"compressed": true,
"content": {
"homeassistant": true,
Expand All @@ -38,6 +39,7 @@
"location": null,
"locations": [null],
"protected": false,
"protected_locations": [],
"compressed": true,
"content": {
"homeassistant": false,
Expand Down
25 changes: 25 additions & 0 deletions tests/fixtures/backups_list_protected_locations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"result": "ok",
"data": {
"backups": [
{
"slug": "d9c48f8b",
"name": "test_consolidate",
"date": "2025-01-22T18:09:28.196333+00:00",
"type": "partial",
"size": 0.01,
"size_bytes": 10240,
"location": null,
"locations": [null, "test"],
"protected": true,
"protected_locations": [null, "test"],
"compressed": true,
"content": {
"homeassistant": false,
"addons": [],
"folders": ["ssl"]
}
}
]
}
}
30 changes: 30 additions & 0 deletions tests/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,33 @@ async def test_full_backup_model(
"""Test full backup model parsing and serializing."""
assert FullBackupOptions.from_dict(as_dict) == options
assert options.to_dict() == as_dict


async def test_backups_list_protected_locations(
responses: aioresponses,
supervisor_client: SupervisorClient,
) -> None:
"""Test protected locations field in backups list."""
responses.get(
f"{SUPERVISOR_URL}/backups",
status=200,
body=load_fixture("backups_list_protected_locations.json"),
)

result = await supervisor_client.backups.list()
assert result[0].protected_locations == {None, "test"}


async def test_backup_info_protected_locations(
responses: aioresponses,
supervisor_client: SupervisorClient,
) -> None:
"""Test protected locations field in backup info."""
responses.get(
f"{SUPERVISOR_URL}/backups/d9c48f8b/info",
status=200,
body=load_fixture("backup_info_protected_locations.json"),
)

result = await supervisor_client.backups.backup_info("d9c48f8b")
assert result.protected_locations == {None, "test"}
Loading