mirror of
https://github.com/home-assistant/core.git
synced 2026-08-16 10:13:55 +01:00
Use version_pending to finalize HAOS update state (#177155)
This commit is contained in:
@@ -257,7 +257,9 @@ class SupervisorOSUpdateEntity(HassioOSEntity, UpdateEntity):
|
||||
def installed_version(self) -> str | None:
|
||||
"""Return the installed version."""
|
||||
assert self.coordinator.data.os is not None
|
||||
return self.coordinator.data.os.version
|
||||
return (
|
||||
self.coordinator.data.os.version_pending or self.coordinator.data.os.version
|
||||
)
|
||||
|
||||
@property
|
||||
@override
|
||||
|
||||
@@ -71,6 +71,7 @@ def mock_all(
|
||||
os_info.return_value,
|
||||
version="1.0.0dev2221",
|
||||
version_latest="1.0.0dev2222",
|
||||
version_pending=None,
|
||||
update_available=True,
|
||||
)
|
||||
supervisor_info.return_value = replace(
|
||||
@@ -540,10 +541,11 @@ async def test_update_os(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
async def mock_os_update(*args: Any) -> None:
|
||||
"""Simulate Supervisor reporting the new version after the update."""
|
||||
"""Simulate Supervisor keeping version stable while pending version updates."""
|
||||
os_info.return_value = replace(
|
||||
os_info.return_value,
|
||||
version="1.0.0dev2222",
|
||||
version="1.0.0dev2221",
|
||||
version_pending="1.0.0dev2222",
|
||||
update_available=False,
|
||||
)
|
||||
|
||||
@@ -560,8 +562,8 @@ async def test_update_os(
|
||||
mock_create_backup.assert_not_called()
|
||||
supervisor_client.os.update.assert_called_once_with(OSUpdate(version=None))
|
||||
|
||||
# The coordinator is refreshed after install so the new version
|
||||
# shows up immediately
|
||||
# The coordinator refresh reflects the new pending version while
|
||||
# the base version remains unchanged.
|
||||
state = hass.states.get("update.home_assistant_operating_system_update")
|
||||
assert state is not None
|
||||
assert state.state == "off"
|
||||
|
||||
Reference in New Issue
Block a user