Add issues/suggestion to resolution center / start with diskspace (#2125)

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
Joakim Sørensen
2020-10-14 17:14:25 +02:00
committed by GitHub
parent d599c3ad76
commit 02e72726a5
13 changed files with 375 additions and 27 deletions

View File

@@ -1,13 +1,47 @@
"""Test Resolution API."""
from unittest.mock import MagicMock, patch
import pytest
from supervisor.const import ATTR_UNSUPPORTED, UnsupportedReason
from supervisor.const import ATTR_ISSUES, ATTR_SUGGESTIONS, ATTR_UNSUPPORTED
from supervisor.coresys import CoreSys
from supervisor.resolution.const import IssueType, Suggestion, UnsupportedReason
@pytest.mark.asyncio
async def test_api_resolution_base(coresys, api_client):
async def test_api_resolution_base(coresys: CoreSys, api_client):
"""Test resolution manager api."""
coresys.resolution.unsupported = UnsupportedReason.OS
coresys.resolution.suggestions = Suggestion.CLEAR_FULL_SNAPSHOT
coresys.resolution.issues = IssueType.FREE_SPACE
resp = await api_client.get("/resolution")
result = await resp.json()
assert UnsupportedReason.OS in result["data"][ATTR_UNSUPPORTED]
assert Suggestion.CLEAR_FULL_SNAPSHOT in result["data"][ATTR_SUGGESTIONS]
assert IssueType.FREE_SPACE in result["data"][ATTR_ISSUES]
@pytest.mark.asyncio
async def test_api_resolution_dismiss_suggestion(coresys: CoreSys, api_client):
"""Test resolution manager suggestion apply api."""
coresys.resolution.suggestions = Suggestion.CLEAR_FULL_SNAPSHOT
assert Suggestion.CLEAR_FULL_SNAPSHOT in coresys.resolution.suggestions
await coresys.resolution.dismiss_suggestion(Suggestion.CLEAR_FULL_SNAPSHOT)
assert Suggestion.CLEAR_FULL_SNAPSHOT not in coresys.resolution.suggestions
@pytest.mark.asyncio
async def test_api_resolution_apply_suggestion(coresys: CoreSys, api_client):
"""Test resolution manager suggestion apply api."""
coresys.resolution.suggestions = Suggestion.CLEAR_FULL_SNAPSHOT
coresys.resolution.suggestions = Suggestion.CREATE_FULL_SNAPSHOT
with patch("supervisor.snapshots.SnapshotManager", return_value=MagicMock()):
await coresys.resolution.apply_suggestion(Suggestion.CLEAR_FULL_SNAPSHOT)
await coresys.resolution.apply_suggestion(Suggestion.CREATE_FULL_SNAPSHOT)
assert Suggestion.CLEAR_FULL_SNAPSHOT not in coresys.resolution.suggestions
assert Suggestion.CREATE_FULL_SNAPSHOT not in coresys.resolution.suggestions
await coresys.resolution.apply_suggestion(Suggestion.CLEAR_FULL_SNAPSHOT)