From 33385b46a7484d04fc5aa7d3e69e9ba4b11e33f1 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 1 Mar 2021 17:19:38 +0100 Subject: [PATCH] Fix add-on is not installed anymore (#2656) * Fix add-on is not installed anymore * Fix and add tests --- supervisor/resolution/checks/addon_pwned.py | 2 +- tests/resolution/check/test_check_addon_pwned.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/supervisor/resolution/checks/addon_pwned.py b/supervisor/resolution/checks/addon_pwned.py index 3c323edf0..1fcc67d23 100644 --- a/supervisor/resolution/checks/addon_pwned.py +++ b/supervisor/resolution/checks/addon_pwned.py @@ -57,7 +57,7 @@ class CheckAddonPwned(CheckBase): addon = self.sys_addons.get(reference) # Uninstalled - if not addon: + if not addon or not addon.is_installed: return False # Not in use anymore diff --git a/tests/resolution/check/test_check_addon_pwned.py b/tests/resolution/check/test_check_addon_pwned.py index 3c6844d93..ec27de9bf 100644 --- a/tests/resolution/check/test_check_addon_pwned.py +++ b/tests/resolution/check/test_check_addon_pwned.py @@ -14,6 +14,7 @@ class TestAddon: slug = "my_test" pwned = set() state = AddonState.STARTED + is_installed = True async def test_check(coresys: CoreSys): @@ -78,6 +79,13 @@ async def test_approve(coresys: CoreSys): ): assert not await addon_pwned.approve_check(reference=addon.slug) + addon.is_installed = False + with patch( + "supervisor.resolution.checks.addon_pwned.check_pwned_password", + AsyncMock(return_value=True), + ): + assert not await addon_pwned.approve_check(reference=addon.slug) + async def test_did_run(coresys: CoreSys): """Test that the check ran as expected."""