mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-05-08 08:58:31 +01:00
Extend backup API with file name field (#5567)
* Extend backup API with file name field Allow to specify a backup file name when creating a backup. This allows for user friendly backup file names. If none is specified, the current behavior remains (backup file name is the backup slug). * Check passed file name using regex * Use custom filename on download only if backup file name is backup slug * ruff format * Remove path from location for download file name
This commit is contained in:
@@ -73,6 +73,28 @@ async def test_do_backup_full(coresys: CoreSys, backup_mock, install_addon_ssh):
|
||||
assert coresys.core.state == CoreState.RUNNING
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("filename", "filename_expected"),
|
||||
[("../my file.tar", "/data/backup/my file.tar"), (None, "/data/backup/{}.tar")],
|
||||
)
|
||||
async def test_do_backup_full_with_filename(
|
||||
coresys: CoreSys, filename: str, filename_expected: str, backup_mock
|
||||
):
|
||||
"""Test creating Backup with a specific file name."""
|
||||
coresys.core.state = CoreState.RUNNING
|
||||
coresys.hardware.disk.get_disk_free_space = lambda x: 5000
|
||||
|
||||
manager = BackupManager(coresys)
|
||||
|
||||
# backup_mock fixture causes Backup() to be a MagicMock
|
||||
await manager.do_backup_full(filename=filename)
|
||||
|
||||
slug = backup_mock.call_args[0][2]
|
||||
assert str(backup_mock.call_args[0][1]) == filename_expected.format(slug)
|
||||
|
||||
assert coresys.core.state == CoreState.RUNNING
|
||||
|
||||
|
||||
async def test_do_backup_full_uncompressed(
|
||||
coresys: CoreSys, backup_mock, install_addon_ssh
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user