mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-10-17 07:39:33 +00:00
Allow home assistant backups to exclude database (#4591)
* Allow home assistant backups to exclude database * Tweak Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch> --------- Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
"""Test homeassistant api."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
import pytest
|
||||
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.homeassistant.module import HomeAssistant
|
||||
|
||||
from tests.common import load_json_fixture
|
||||
|
||||
@@ -39,3 +40,26 @@ async def test_api_stats(api_client: TestClient, coresys: CoreSys):
|
||||
assert result["data"]["memory_usage"] == 59700000
|
||||
assert result["data"]["memory_limit"] == 4000000000
|
||||
assert result["data"]["memory_percent"] == 1.49
|
||||
|
||||
|
||||
async def test_api_set_options(api_client: TestClient, coresys: CoreSys):
|
||||
"""Test setting options for homeassistant."""
|
||||
resp = await api_client.get("/homeassistant/info")
|
||||
assert resp.status == 200
|
||||
result = await resp.json()
|
||||
assert result["data"]["watchdog"] is True
|
||||
assert result["data"]["backups_exclude_database"] is False
|
||||
|
||||
with patch.object(HomeAssistant, "save_data") as save_data:
|
||||
resp = await api_client.post(
|
||||
"/homeassistant/options",
|
||||
json={"backups_exclude_database": True, "watchdog": False},
|
||||
)
|
||||
assert resp.status == 200
|
||||
save_data.assert_called_once()
|
||||
|
||||
resp = await api_client.get("/homeassistant/info")
|
||||
assert resp.status == 200
|
||||
result = await resp.json()
|
||||
assert result["data"]["watchdog"] is False
|
||||
assert result["data"]["backups_exclude_database"] is True
|
||||
|
Reference in New Issue
Block a user