Add auto update option (#3769)

* Add update freeze option

* Freeze to auto update and plugin condition

* Add tests

* Add supervisor_version evaluation

* OS updates require supervisor up to date

* Run version check during startup
This commit is contained in:
Mike Degatano
2022-08-15 12:13:22 -04:00
committed by GitHub
parent e82cb5da45
commit c8f184f24c
33 changed files with 436 additions and 37 deletions

View File

@@ -0,0 +1,22 @@
"""Test Home Assistant core."""
from unittest.mock import PropertyMock, patch
import pytest
from supervisor.coresys import CoreSys
from supervisor.exceptions import HomeAssistantJobError
async def test_update_fails_if_out_of_date(coresys: CoreSys):
"""Test update of Home Assistant fails when supervisor or plugin is out of date."""
coresys.hardware.disk.get_disk_free_space = lambda x: 5000
with patch.object(
type(coresys.supervisor), "need_update", new=PropertyMock(return_value=True)
), pytest.raises(HomeAssistantJobError):
await coresys.homeassistant.core.update()
with patch.object(
type(coresys.plugins.audio), "need_update", new=PropertyMock(return_value=True)
), pytest.raises(HomeAssistantJobError):
await coresys.homeassistant.core.update()