mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-24 20:35:55 +00:00
Backup protected status can vary per location (#5569)
* Backup protected status can vary per location * Fix test_backup_remove_error test * Update supervisor/backups/backup.py * Add Docker registry configuration to backup metadata * Make use of backup location fixture * Address pylint --------- Co-authored-by: Stefan Agner <stefan@agner.ch>
This commit is contained in:
@@ -2,11 +2,16 @@
|
||||
|
||||
from os import listdir
|
||||
from pathlib import Path
|
||||
from shutil import copy
|
||||
|
||||
import pytest
|
||||
|
||||
from supervisor.backups.backup import Backup
|
||||
from supervisor.backups.const import BackupType
|
||||
from supervisor.coresys import CoreSys
|
||||
|
||||
from tests.common import get_fixture_path
|
||||
|
||||
|
||||
async def test_new_backup_stays_in_folder(coresys: CoreSys, tmp_path: Path):
|
||||
"""Test making a new backup operates entirely within folder where backup will be stored."""
|
||||
@@ -20,3 +25,23 @@ async def test_new_backup_stays_in_folder(coresys: CoreSys, tmp_path: Path):
|
||||
|
||||
assert len(listdir(tmp_path)) == 1
|
||||
assert backup.tarfile.exists()
|
||||
|
||||
|
||||
async def test_consolidate_conflict_varied_encryption(
|
||||
coresys: CoreSys, tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
):
|
||||
"""Test consolidate with two backups in same location and varied encryption."""
|
||||
enc_tar = Path(copy(get_fixture_path("test_consolidate.tar"), tmp_path))
|
||||
enc_backup = Backup(coresys, enc_tar, "test", None)
|
||||
await enc_backup.load()
|
||||
|
||||
unc_tar = Path(copy(get_fixture_path("test_consolidate_unc.tar"), tmp_path))
|
||||
unc_backup = Backup(coresys, unc_tar, "test", None)
|
||||
await unc_backup.load()
|
||||
|
||||
enc_backup.consolidate(unc_backup)
|
||||
assert (
|
||||
f"Backup d9c48f8b exists in two files in locations None. Ignoring {enc_tar.as_posix()}"
|
||||
in caplog.text
|
||||
)
|
||||
assert enc_backup.all_locations == {None: {"path": unc_tar, "protected": False}}
|
||||
|
||||
Reference in New Issue
Block a user