diff --git a/supervisor/api/__init__.py b/supervisor/api/__init__.py index b04c2ac5602..f4ced1bdffb 100644 --- a/supervisor/api/__init__.py +++ b/supervisor/api/__init__.py @@ -345,6 +345,9 @@ def _register_root(self) -> None: 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)] diff --git a/supervisor/api/root.py b/supervisor/api/root.py index 6c74d7bdcba..00a9d0c1ac9 100644 --- a/supervisor/api/root.py +++ b/supervisor/api/root.py @@ -113,3 +113,8 @@ async def refresh_updates(self, request: web.Request) -> None: 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() diff --git a/tests/api/test_root.py b/tests/api/test_root.py index a497f97c505..9d233ace0a5 100644 --- a/tests/api/test_root.py +++ b/tests/api/test_root.py @@ -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