mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 20:26:29 +00:00
Resolution: API call for run check manual (#2719)
This commit is contained in:
parent
059233c111
commit
b1232c0d8d
@ -231,6 +231,7 @@ class RestAPI(CoreSysAttributes):
|
|||||||
web.post(
|
web.post(
|
||||||
"/resolution/check/{check}/options", api_resolution.options_check
|
"/resolution/check/{check}/options", api_resolution.options_check
|
||||||
),
|
),
|
||||||
|
web.post("/resolution/check/{check}/run", api_resolution.run_check),
|
||||||
web.post(
|
web.post(
|
||||||
"/resolution/suggestion/{suggestion}",
|
"/resolution/suggestion/{suggestion}",
|
||||||
api_resolution.apply_suggestion,
|
api_resolution.apply_suggestion,
|
||||||
|
@ -93,3 +93,13 @@ class APIResoulution(CoreSysAttributes):
|
|||||||
check.enabled = body[ATTR_ENABLED]
|
check.enabled = body[ATTR_ENABLED]
|
||||||
|
|
||||||
self.sys_resolution.save_data()
|
self.sys_resolution.save_data()
|
||||||
|
|
||||||
|
@api_process
|
||||||
|
async def run_check(self, request: web.Request) -> None:
|
||||||
|
"""Execute a backend check."""
|
||||||
|
try:
|
||||||
|
check = self.sys_resolution.check.get(request.match_info.get("check"))
|
||||||
|
except ResolutionNotFound:
|
||||||
|
raise APIError("The supplied check slug is not available") from None
|
||||||
|
|
||||||
|
await check()
|
||||||
|
@ -8,6 +8,7 @@ from supervisor.const import (
|
|||||||
ATTR_SUGGESTIONS,
|
ATTR_SUGGESTIONS,
|
||||||
ATTR_UNHEALTHY,
|
ATTR_UNHEALTHY,
|
||||||
ATTR_UNSUPPORTED,
|
ATTR_UNSUPPORTED,
|
||||||
|
CoreState,
|
||||||
)
|
)
|
||||||
from supervisor.coresys import CoreSys
|
from supervisor.coresys import CoreSys
|
||||||
from supervisor.exceptions import ResolutionError
|
from supervisor.exceptions import ResolutionError
|
||||||
@ -117,3 +118,16 @@ async def test_api_resolution_check_options(coresys: CoreSys, api_client):
|
|||||||
f"/resolution/check/{free_space.slug}/options", json={"enabled": True}
|
f"/resolution/check/{free_space.slug}/options", json={"enabled": True}
|
||||||
)
|
)
|
||||||
assert free_space.enabled
|
assert free_space.enabled
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_api_resolution_check_run(coresys: CoreSys, api_client):
|
||||||
|
"""Test client API with run check."""
|
||||||
|
coresys.core.state = CoreState.RUNNING
|
||||||
|
free_space = coresys.resolution.check.get("free_space")
|
||||||
|
|
||||||
|
free_space.run_check = AsyncMock()
|
||||||
|
|
||||||
|
await api_client.post(f"/resolution/check/{free_space.slug}/run")
|
||||||
|
|
||||||
|
assert free_space.run_check.called
|
||||||
|
Loading…
x
Reference in New Issue
Block a user