mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Add dedicated version update refresh for main components (#5833)
* Add dedicated update information reload Currently we have the /refresh_updates endpoint which updates the main component versions (Core, OS, Supervisor, Plug-ins) and the add-on store at the same time. This combined update causes more update information reloads than necessary. To allow fine grained update refresh control introduce a new endpoint /reload_updates which asks Supervisor to only update main component versions (learned through the version json files). The /store/reload endpoint already allows to update the add-on store separately. * Add pytest * Update supervisor/api/__init__.py
This commit is contained in:
parent
88b41e80bb
commit
de497cdc19
@ -345,6 +345,9 @@ class RestAPI(CoreSysAttributes):
|
||||
api_root.coresys = self.coresys
|
||||
|
||||
self.webapp.add_routes([web.get("/info", api_root.info)])
|
||||
self.webapp.add_routes([web.post("/reload_updates", api_root.reload_updates)])
|
||||
|
||||
# Discouraged
|
||||
self.webapp.add_routes([web.post("/refresh_updates", api_root.refresh_updates)])
|
||||
self.webapp.add_routes(
|
||||
[web.get("/available_updates", api_root.available_updates)]
|
||||
|
@ -113,3 +113,8 @@ class APIRoot(CoreSysAttributes):
|
||||
await asyncio.shield(
|
||||
asyncio.gather(self.sys_updater.reload(), self.sys_store.reload())
|
||||
)
|
||||
|
||||
@api_process
|
||||
async def reload_updates(self, request: web.Request) -> None:
|
||||
"""Refresh updater update information."""
|
||||
await self.sys_updater.reload()
|
||||
|
@ -1,7 +1,9 @@
|
||||
"""Test Supervisor API."""
|
||||
|
||||
# pylint: disable=protected-access
|
||||
from unittest.mock import AsyncMock
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
|
||||
from supervisor.api.const import ATTR_AVAILABLE_UPDATES
|
||||
from supervisor.coresys import CoreSys
|
||||
@ -78,3 +80,18 @@ async def test_api_refresh_updates(api_client, coresys: CoreSys):
|
||||
|
||||
assert coresys.updater.reload.called
|
||||
assert coresys.store.reload.called
|
||||
|
||||
|
||||
async def test_api_reload_updates(
|
||||
coresys: CoreSys,
|
||||
api_client: TestClient,
|
||||
):
|
||||
"""Test reload updates."""
|
||||
with (
|
||||
patch("supervisor.updater.Updater.fetch_data") as fetch_data,
|
||||
):
|
||||
resp = await api_client.post("/reload_updates")
|
||||
|
||||
fetch_data.assert_called_once_with()
|
||||
|
||||
assert resp.status == 200
|
||||
|
Loading…
x
Reference in New Issue
Block a user