From 2a6fc512e7ff78927ebc9b92d0175187408d8821 Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Thu, 22 Sep 2022 10:52:07 -0400 Subject: [PATCH] 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 --- tests/resolution/check/test_check.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/resolution/check/test_check.py b/tests/resolution/check/test_check.py index 1f7c569fc..7bf77b57c 100644 --- a/tests/resolution/check/test_check.py +++ b/tests/resolution/check/test_check.py @@ -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):