mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-09 10:59:43 +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:
45
tests/api/test_backups.py
Normal file
45
tests/api/test_backups.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""Test backups API."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from supervisor.backups.backup import Backup
|
||||
from supervisor.coresys import CoreSys
|
||||
|
||||
|
||||
async def test_info(api_client, coresys: CoreSys, mock_full_backup: Backup):
|
||||
"""Test info endpoint."""
|
||||
resp = await api_client.get("/backups/info")
|
||||
result = await resp.json()
|
||||
assert result["data"]["days_until_stale"] == 30
|
||||
assert len(result["data"]["backups"]) == 1
|
||||
assert result["data"]["backups"][0]["slug"] == "test"
|
||||
assert result["data"]["backups"][0]["content"]["homeassistant"] is True
|
||||
assert len(result["data"]["backups"][0]["content"]["addons"]) == 1
|
||||
assert result["data"]["backups"][0]["content"]["addons"][0] == "local_ssh"
|
||||
|
||||
|
||||
async def test_list(api_client, coresys: CoreSys, mock_full_backup: Backup):
|
||||
"""Test list endpoint."""
|
||||
resp = await api_client.get("/backups")
|
||||
result = await resp.json()
|
||||
assert len(result["data"]["backups"]) == 1
|
||||
assert result["data"]["backups"][0]["slug"] == "test"
|
||||
assert result["data"]["backups"][0]["content"]["homeassistant"] is True
|
||||
assert len(result["data"]["backups"][0]["content"]["addons"]) == 1
|
||||
assert result["data"]["backups"][0]["content"]["addons"][0] == "local_ssh"
|
||||
|
||||
|
||||
async def test_options(api_client, coresys: CoreSys):
|
||||
"""Test options endpoint."""
|
||||
assert coresys.backups.days_until_stale == 30
|
||||
|
||||
with patch.object(type(coresys.backups), "save_data") as save_data:
|
||||
await api_client.post(
|
||||
"/backups/options",
|
||||
json={
|
||||
"days_until_stale": 10,
|
||||
},
|
||||
)
|
||||
save_data.assert_called_once()
|
||||
|
||||
assert coresys.backups.days_until_stale == 10
|
||||
Reference in New Issue
Block a user