Skip to content

Commit eaa2558

Browse files
authored
Add filename input to backup APIs (#43)
1 parent c61384b commit eaa2558

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

aiohasupervisor/models/backups.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from dataclasses import dataclass
55
from datetime import datetime
66
from enum import StrEnum
7+
from pathlib import PurePath
78

89
from .base import DEFAULT, Request, ResponseData
910

@@ -145,6 +146,7 @@ class FullBackupOptions(Request):
145146
homeassistant_exclude_database: bool | None = None
146147
background: bool | None = None
147148
extra: dict | None = None
149+
filename: PurePath | None = None
148150

149151

150152
@dataclass(frozen=True, slots=True)

tests/test_backups.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
from collections.abc import AsyncIterator
55
from datetime import UTC, datetime
6+
from pathlib import PurePath
67
from typing import Any
78

89
from aioresponses import CallbackResult, aioresponses
@@ -188,6 +189,12 @@ def backup_callback(url: str, **kwargs: dict[str, Any]) -> CallbackResult: # no
188189
"9ecf0028",
189190
),
190191
(FullBackupOptions(name="Test", background=False, extra=None), "9ecf0028"),
192+
(
193+
FullBackupOptions(
194+
name="test", background=False, filename=PurePath("backup.tar")
195+
),
196+
"9ecf0028",
197+
),
191198
(None, "9ecf0028"),
192199
],
193200
)
@@ -251,6 +258,15 @@ async def test_backups_full_backup(
251258
),
252259
"9ecf0028",
253260
),
261+
(
262+
PartialBackupOptions(
263+
name="Test",
264+
background=False,
265+
addons={"core_ssh"},
266+
filename=PurePath("backup.tar"),
267+
),
268+
"9ecf0028",
269+
),
254270
(
255271
PartialBackupOptions(name="Test", background=None, addons={"core_ssh"}),
256272
"9ecf0028",
@@ -520,6 +536,10 @@ async def test_download_backup(
520536
PartialBackupOptions(homeassistant=True, location=None),
521537
{"homeassistant": True, "location": None},
522538
),
539+
(
540+
PartialBackupOptions(homeassistant=True, filename=PurePath("backup.tar")),
541+
{"homeassistant": True, "filename": "backup.tar"},
542+
),
523543
],
524544
)
525545
async def test_partial_backup_model(
@@ -547,6 +567,10 @@ async def test_partial_backup_model(
547567
),
548568
(FullBackupOptions(location="test"), {"location": "test"}),
549569
(FullBackupOptions(location=None), {"location": None}),
570+
(
571+
FullBackupOptions(filename=PurePath("backup.tar")),
572+
{"filename": "backup.tar"},
573+
),
550574
],
551575
)
552576
async def test_full_backup_model(

0 commit comments

Comments
 (0)