From 622970c86709227f12f94f06e9783c573b2ba7e3 Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Thu, 21 Nov 2024 16:46:06 -0500 Subject: [PATCH] Fix issues in backup model (#30) --- aiohasupervisor/models/backups.py | 6 ++-- .../backup_info_no_homeassistant.json | 32 +++++++++++++++++++ tests/test_backups.py | 15 +++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/backup_info_no_homeassistant.json diff --git a/aiohasupervisor/models/backups.py b/aiohasupervisor/models/backups.py index 51d5640..4a81f53 100644 --- a/aiohasupervisor/models/backups.py +++ b/aiohasupervisor/models/backups.py @@ -35,7 +35,7 @@ class BackupContent(ResponseData): homeassistant: bool addons: list[str] - folders: list[str] + folders: list[Folder] @dataclass(frozen=True) @@ -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 diff --git a/tests/fixtures/backup_info_no_homeassistant.json b/tests/fixtures/backup_info_no_homeassistant.json new file mode 100644 index 0000000..11076de --- /dev/null +++ b/tests/fixtures/backup_info_no_homeassistant.json @@ -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 + } +} diff --git a/tests/test_backups.py b/tests/test_backups.py index b2bea76..2eb8a91 100644 --- a/tests/test_backups.py +++ b/tests/test_backups.py @@ -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: