Fix add-on is not installed anymore (#2656)

* Fix add-on is not installed anymore

* Fix and add tests
This commit is contained in:
Pascal Vizeli 2021-03-01 17:19:38 +01:00 committed by GitHub
parent 43449c85bb
commit 33385b46a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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."""