Skip to content

Commit 136c0cd

Browse files
authored
Add reload updates for main components (#90)
* Add reload updates for main components Add /reload_updates endpoint which refreshes updates of the main components only (OS, Supervisor, Core and Plug-ins). * Discourage /refresh_updates only * Add pytest * Add discouraged explanation
1 parent fd76d82 commit 136c0cd

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

aiohasupervisor/root.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,19 @@ async def info(self) -> RootInfo:
109109
result = await self._client.get("info")
110110
return RootInfo.from_dict(result.data)
111111

112+
async def reload_updates(self) -> None:
113+
"""Reload updates.
114+
115+
Reload main components update information (OS, Supervisor, Core and plug-ins).
116+
"""
117+
await self._client.post("reload_updates", timeout=ClientTimeout(total=300))
118+
112119
async def refresh_updates(self) -> None:
113-
"""Refresh updates."""
120+
"""Refresh updates.
121+
122+
Discouraged as this endpoint does two things at once. Use the `reload_updates()`
123+
and `store.reload()` instead.
124+
"""
114125
await self._client.post("refresh_updates", timeout=ClientTimeout(total=300))
115126

116127
async def available_updates(self) -> list[AvailableUpdate]:

tests/test_root.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ async def test_available_updates(
8888
assert updates[1].update_type == UpdateType.OS
8989

9090

91+
async def test_reload_updates(
92+
responses: aioresponses, supervisor_client: SupervisorClient
93+
) -> None:
94+
"""Test reload updates API."""
95+
responses.post(f"{SUPERVISOR_URL}/reload_updates", status=200)
96+
assert await supervisor_client.reload_updates() is None
97+
assert responses.requests.keys() == {
98+
("POST", URL(f"{SUPERVISOR_URL}/reload_updates"))
99+
}
100+
101+
91102
async def test_refresh_updates(
92103
responses: aioresponses, supervisor_client: SupervisorClient
93104
) -> None:

0 commit comments

Comments
 (0)