Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filename input to backup APIs #43

Merged
merged 1 commit into from
Jan 28, 2025
Merged
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
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
Loading