diff --git a/supervisor/jobs/decorator.py b/supervisor/jobs/decorator.py index 9c3356303..d990d9e8b 100644 --- a/supervisor/jobs/decorator.py +++ b/supervisor/jobs/decorator.py @@ -179,7 +179,7 @@ class Job(CoreSysAttributes): if JobCondition.HEALTHY in used_conditions and not self.sys_core.healthy: 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 ( diff --git a/tests/jobs/test_job_decorator.py b/tests/jobs/test_job_decorator.py index 3eb5d02d9..cde306439 100644 --- a/tests/jobs/test_job_decorator.py +++ b/tests/jobs/test_job_decorator.py @@ -488,3 +488,27 @@ async def test_auto_update(coresys: CoreSys): coresys.updater.auto_update = False 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()