Skip to content

Commit

Permalink
Add filename input to backup APIs (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 authored Jan 28, 2025
1 parent c61384b commit eaa2558
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aiohasupervisor/models/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dataclasses import dataclass
from datetime import datetime
from enum import StrEnum
from pathlib import PurePath

from .base import DEFAULT, Request, ResponseData

Expand Down Expand Up @@ -145,6 +146,7 @@ class FullBackupOptions(Request):
homeassistant_exclude_database: bool | None = None
background: bool | None = None
extra: dict | None = None
filename: PurePath | None = None


@dataclass(frozen=True, slots=True)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
from collections.abc import AsyncIterator
from datetime import UTC, datetime
from pathlib import PurePath
from typing import Any

from aioresponses import CallbackResult, aioresponses
Expand Down Expand Up @@ -188,6 +189,12 @@ def backup_callback(url: str, **kwargs: dict[str, Any]) -> CallbackResult: # no
"9ecf0028",
),
(FullBackupOptions(name="Test", background=False, extra=None), "9ecf0028"),
(
FullBackupOptions(
name="test", background=False, filename=PurePath("backup.tar")
),
"9ecf0028",
),
(None, "9ecf0028"),
],
)
Expand Down Expand Up @@ -251,6 +258,15 @@ async def test_backups_full_backup(
),
"9ecf0028",
),
(
PartialBackupOptions(
name="Test",
background=False,
addons={"core_ssh"},
filename=PurePath("backup.tar"),
),
"9ecf0028",
),
(
PartialBackupOptions(name="Test", background=None, addons={"core_ssh"}),
"9ecf0028",
Expand Down Expand Up @@ -520,6 +536,10 @@ async def test_download_backup(
PartialBackupOptions(homeassistant=True, location=None),
{"homeassistant": True, "location": None},
),
(
PartialBackupOptions(homeassistant=True, filename=PurePath("backup.tar")),
{"homeassistant": True, "filename": "backup.tar"},
),
],
)
async def test_partial_backup_model(
Expand Down Expand Up @@ -547,6 +567,10 @@ async def test_partial_backup_model(
),
(FullBackupOptions(location="test"), {"location": "test"}),
(FullBackupOptions(location=None), {"location": None}),
(
FullBackupOptions(filename=PurePath("backup.tar")),
{"filename": "backup.tar"},
),
],
)
async def test_full_backup_model(
Expand Down

0 comments on commit eaa2558

Please sign in to comment.