mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-08 09:46:29 +00:00
Add unhealthy reasons to block message (#3948)
This commit is contained in:
parent
767c2bd91a
commit
9da4ea20a9
@ -179,7 +179,7 @@ class Job(CoreSysAttributes):
|
|||||||
|
|
||||||
if JobCondition.HEALTHY in used_conditions and not self.sys_core.healthy:
|
if JobCondition.HEALTHY in used_conditions and not self.sys_core.healthy:
|
||||||
raise JobConditionException(
|
raise JobConditionException(
|
||||||
f"'{self._method.__qualname__}' blocked from execution, system is not healthy"
|
f"'{self._method.__qualname__}' blocked from execution, system is not healthy - {', '.join(self.sys_resolution.unhealthy)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -488,3 +488,27 @@ async def test_auto_update(coresys: CoreSys):
|
|||||||
|
|
||||||
coresys.updater.auto_update = False
|
coresys.updater.auto_update = False
|
||||||
assert not await test.execute()
|
assert not await test.execute()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_unhealthy(coresys: CoreSys, caplog: pytest.LogCaptureFixture):
|
||||||
|
"""Test the healthy decorator when unhealthy."""
|
||||||
|
|
||||||
|
class TestClass:
|
||||||
|
"""Test class."""
|
||||||
|
|
||||||
|
def __init__(self, coresys: CoreSys):
|
||||||
|
"""Initialize the test class."""
|
||||||
|
self.coresys = coresys
|
||||||
|
|
||||||
|
@Job(conditions=[JobCondition.HEALTHY])
|
||||||
|
async def execute(self) -> bool:
|
||||||
|
"""Execute the class method."""
|
||||||
|
return True
|
||||||
|
|
||||||
|
test = TestClass(coresys)
|
||||||
|
coresys.resolution.unhealthy = UnhealthyReason.SETUP
|
||||||
|
assert not await test.execute()
|
||||||
|
assert "blocked from execution, system is not healthy - setup" in caplog.text
|
||||||
|
|
||||||
|
coresys.jobs.ignore_conditions = [JobCondition.HEALTHY]
|
||||||
|
assert await test.execute()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user