Check if issue in list, not end of list in test (#3891)

* Check if issue in list, not end of list

* Similar fix to other test
This commit is contained in:
Mike Degatano 2022-09-22 10:52:07 -04:00 committed by GitHub
parent bb0d89f8fd
commit 2a6fc512e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,8 @@ import pytest
from supervisor.const import CoreState
from supervisor.coresys import CoreSys
from supervisor.exceptions import ResolutionNotFound
from supervisor.resolution.const import IssueType
from supervisor.resolution.const import ContextType, IssueType
from supervisor.resolution.data import Issue
from supervisor.resolution.validate import get_valid_modules
@ -48,29 +49,31 @@ async def test_check_running(coresys: CoreSys):
async def test_if_check_make_issue(coresys: CoreSys):
"""Test check for setup."""
free_space = Issue(IssueType.FREE_SPACE, ContextType.SYSTEM)
coresys.core.state = CoreState.RUNNING
coresys.security.content_trust = False
with patch("shutil.disk_usage", return_value=(1, 1, 1)):
await coresys.resolution.check.check_system()
assert coresys.resolution.issues[-1].type == IssueType.FREE_SPACE
assert free_space in coresys.resolution.issues
async def test_if_check_cleanup_issue(coresys: CoreSys, mock_full_backup):
async def test_if_check_cleanup_issue(coresys: CoreSys):
"""Test check for setup."""
free_space = Issue(IssueType.FREE_SPACE, ContextType.SYSTEM)
coresys.core.state = CoreState.RUNNING
coresys.security.content_trust = False
with patch("shutil.disk_usage", return_value=(1, 1, 1)):
await coresys.resolution.check.check_system()
assert coresys.resolution.issues[-1].type == IssueType.FREE_SPACE
assert free_space in coresys.resolution.issues
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0**3))):
await coresys.resolution.check.check_system()
assert len(coresys.resolution.issues) == 0
assert free_space not in coresys.resolution.issues
async def test_enable_disable_checks(coresys: CoreSys):