diff --git a/supervisor/os/manager.py b/supervisor/os/manager.py index 5763f538f..f99673925 100644 --- a/supervisor/os/manager.py +++ b/supervisor/os/manager.py @@ -272,6 +272,7 @@ class OSManager(CoreSysAttributes): name="os_manager_update", conditions=[ JobCondition.HAOS, + JobCondition.HEALTHY, JobCondition.INTERNET_SYSTEM, JobCondition.RUNNING, JobCondition.SUPERVISOR_UPDATED, diff --git a/tests/os/test_manager.py b/tests/os/test_manager.py index 70370064a..8970c9ace 100644 --- a/tests/os/test_manager.py +++ b/tests/os/test_manager.py @@ -9,6 +9,7 @@ import pytest from supervisor.const import CoreState from supervisor.coresys import CoreSys from supervisor.exceptions import HassOSJobError +from supervisor.resolution.const import UnhealthyReason from tests.common import MockResponse from tests.dbus_service_mocks.base import DBusServiceMock @@ -85,6 +86,21 @@ async def test_update_fails_if_out_of_date( await coresys.os.update() +async def test_update_fails_if_unhealthy( + coresys: CoreSys, +) -> None: + """Test update of OS fails if Supervisor is unhealthy.""" + await coresys.core.set_state(CoreState.RUNNING) + coresys.resolution.add_unhealthy_reason(UnhealthyReason.DUPLICATE_OS_INSTALLATION) + with ( + patch.object( + type(coresys.os), "available", new=PropertyMock(return_value=True) + ), + pytest.raises(HassOSJobError), + ): + await coresys.os.update() + + async def test_board_name_supervised(coresys: CoreSys) -> None: """Test board name is supervised when not on haos.""" with patch("supervisor.os.manager.CPE.get_product", return_value=["not-hassos"]):