mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-25 04:46:25 +00:00
Create issue+suggestion when no recent backup (#3814)
* Automatic full backup option * Fix test for change in free space check * Suggestions only, no automation * Remove extra in backup config schema
This commit is contained in:
@@ -1,22 +1,16 @@
|
||||
"""Test evaluation base."""
|
||||
"""Test clear full backup fixup."""
|
||||
# pylint: disable=import-error,protected-access
|
||||
from pathlib import Path
|
||||
|
||||
from securetar import SecureTarFile
|
||||
|
||||
from supervisor.backups.backup import Backup
|
||||
from supervisor.backups.const import BackupType
|
||||
from supervisor.const import ATTR_DATE, ATTR_SLUG, ATTR_TYPE
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.resolution.const import ContextType, SuggestionType
|
||||
from supervisor.resolution.data import Suggestion
|
||||
from supervisor.resolution.fixups.system_clear_full_backup import (
|
||||
FixupSystemClearFullBackup,
|
||||
)
|
||||
from supervisor.utils.dt import utcnow
|
||||
|
||||
|
||||
async def test_fixup(coresys: CoreSys, tmp_path):
|
||||
async def test_fixup(coresys: CoreSys, backups: list[Backup]):
|
||||
"""Test fixup."""
|
||||
clear_full_backup = FixupSystemClearFullBackup(coresys)
|
||||
|
||||
@@ -26,20 +20,6 @@ async def test_fixup(coresys: CoreSys, tmp_path):
|
||||
SuggestionType.CLEAR_FULL_BACKUP, ContextType.SYSTEM
|
||||
)
|
||||
|
||||
for slug in ["sn1", "sn2", "sn3", "sn4", "sn5"]:
|
||||
temp_tar = Path(tmp_path, f"{slug}.tar")
|
||||
with SecureTarFile(temp_tar, "w"):
|
||||
pass
|
||||
backup = Backup(coresys, temp_tar)
|
||||
backup._data = { # pylint: disable=protected-access
|
||||
ATTR_SLUG: slug,
|
||||
ATTR_DATE: utcnow().isoformat(),
|
||||
ATTR_TYPE: BackupType.PARTIAL
|
||||
if "1" in slug or "5" in slug
|
||||
else BackupType.FULL,
|
||||
}
|
||||
coresys.backups._backups[backup.slug] = backup
|
||||
|
||||
newest_full_backup = coresys.backups._backups["sn4"]
|
||||
|
||||
assert newest_full_backup in coresys.backups.list_backups
|
||||
@@ -52,7 +32,7 @@ async def test_fixup(coresys: CoreSys, tmp_path):
|
||||
assert newest_full_backup in coresys.backups.list_backups
|
||||
assert (
|
||||
len([x for x in coresys.backups.list_backups if x.sys_type == BackupType.FULL])
|
||||
== 1
|
||||
== 2
|
||||
)
|
||||
|
||||
assert len(coresys.resolution.suggestions) == 0
|
||||
|
||||
Reference in New Issue
Block a user