diff --git a/aiohasupervisor/models/backups.py b/aiohasupervisor/models/backups.py index 541fa1c..7386029 100644 --- a/aiohasupervisor/models/backups.py +++ b/aiohasupervisor/models/backups.py @@ -57,6 +57,7 @@ class BackupBaseFields(ABC): location: str | None locations: set[str | None] protected: bool + protected_locations: set[str | None] compressed: bool diff --git a/tests/fixtures/backup_info.json b/tests/fixtures/backup_info.json index b73cc64..08f76c0 100644 --- a/tests/fixtures/backup_info.json +++ b/tests/fixtures/backup_info.json @@ -9,6 +9,7 @@ "size_bytes": 10123, "compressed": true, "protected": false, + "protected_locations": [], "supervisor_version": "2024.05.0", "homeassistant": null, "location": null, diff --git a/tests/fixtures/backup_info_no_homeassistant.json b/tests/fixtures/backup_info_no_homeassistant.json index 801d693..75993bd 100644 --- a/tests/fixtures/backup_info_no_homeassistant.json +++ b/tests/fixtures/backup_info_no_homeassistant.json @@ -9,6 +9,7 @@ "size_bytes": 120123, "compressed": true, "protected": false, + "protected_locations": [], "supervisor_version": "2023.08.2.dev1002", "homeassistant": null, "location": "Test", diff --git a/tests/fixtures/backup_info_protected_locations.json b/tests/fixtures/backup_info_protected_locations.json new file mode 100644 index 0000000..b2ff3a5 --- /dev/null +++ b/tests/fixtures/backup_info_protected_locations.json @@ -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": {} + } +} diff --git a/tests/fixtures/backup_info_with_extra.json b/tests/fixtures/backup_info_with_extra.json index 5de752b..d0b46f7 100644 --- a/tests/fixtures/backup_info_with_extra.json +++ b/tests/fixtures/backup_info_with_extra.json @@ -9,6 +9,7 @@ "size_bytes": 10123, "compressed": true, "protected": false, + "protected_locations": [], "supervisor_version": "2024.05.0", "homeassistant": null, "location": null, diff --git a/tests/fixtures/backup_info_with_locations.json b/tests/fixtures/backup_info_with_locations.json index eab5855..e91db91 100644 --- a/tests/fixtures/backup_info_with_locations.json +++ b/tests/fixtures/backup_info_with_locations.json @@ -9,6 +9,7 @@ "size_bytes": 10123, "compressed": true, "protected": false, + "protected_locations": [], "supervisor_version": "2024.05.0", "homeassistant": null, "location": null, diff --git a/tests/fixtures/backups_info.json b/tests/fixtures/backups_info.json index 3965a8b..d8d5ecb 100644 --- a/tests/fixtures/backups_info.json +++ b/tests/fixtures/backups_info.json @@ -12,6 +12,7 @@ "location": null, "locations": [null], "protected": false, + "protected_locations": [], "compressed": true, "content": { "homeassistant": true, @@ -38,6 +39,7 @@ "location": null, "locations": [null], "protected": false, + "protected_locations": [], "compressed": true, "content": { "homeassistant": false, diff --git a/tests/fixtures/backups_list.json b/tests/fixtures/backups_list.json index fa3b04f..b812837 100644 --- a/tests/fixtures/backups_list.json +++ b/tests/fixtures/backups_list.json @@ -12,6 +12,7 @@ "location": null, "locations": [null], "protected": false, + "protected_locations": [], "compressed": true, "content": { "homeassistant": true, @@ -38,6 +39,7 @@ "location": null, "locations": [null], "protected": false, + "protected_locations": [], "compressed": true, "content": { "homeassistant": false, diff --git a/tests/fixtures/backups_list_protected_locations.json b/tests/fixtures/backups_list_protected_locations.json new file mode 100644 index 0000000..0909f0e --- /dev/null +++ b/tests/fixtures/backups_list_protected_locations.json @@ -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"] + } + } + ] + } +} diff --git a/tests/test_backups.py b/tests/test_backups.py index 68b44da..2f85dc6 100644 --- a/tests/test_backups.py +++ b/tests/test_backups.py @@ -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"}