* fix: guard dashboard update in Docker * fix(dashboard): align action response type --------- Co-authored-by: Donovan Yohan <donovan-yohan@users.noreply.github.com> Co-authored-by: Donovan Yohan <34756395+donovan-yohan@users.noreply.github.com>
This commit is contained in:
co-authored by
Donovan Yohan
Donovan Yohan
parent
359f2be12e
commit
c1a531d063
@@ -348,6 +348,66 @@ class TestWebServerEndpoints:
|
||||
resp = self.client.post("/api/audio/speak", json={"text": " "})
|
||||
assert resp.status_code == 400
|
||||
|
||||
def test_update_hermes_returns_docker_guidance_without_spawning(self, monkeypatch):
|
||||
import hermes_cli.web_server as web_server
|
||||
|
||||
spawned = False
|
||||
|
||||
def fail_spawn(*_args, **_kwargs):
|
||||
nonlocal spawned
|
||||
spawned = True
|
||||
raise AssertionError("docker update guard should not spawn hermes update")
|
||||
|
||||
monkeypatch.setattr(web_server, "detect_install_method", lambda _root: "docker")
|
||||
monkeypatch.setattr(web_server, "_spawn_hermes_action", fail_spawn)
|
||||
web_server._ACTION_PROCS.pop("hermes-update", None)
|
||||
web_server._ACTION_RESULTS.pop("hermes-update", None)
|
||||
|
||||
resp = self.client.post("/api/hermes/update")
|
||||
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["ok"] is False
|
||||
assert data["name"] == "hermes-update"
|
||||
assert data["pid"] is None
|
||||
assert data["error"] == "docker_update_unsupported"
|
||||
assert "docker pull nousresearch/hermes-agent:latest" in data["message"]
|
||||
assert spawned is False
|
||||
|
||||
status = self.client.get("/api/actions/hermes-update/status")
|
||||
assert status.status_code == 200
|
||||
status_data = status.json()
|
||||
assert status_data["running"] is False
|
||||
assert status_data["exit_code"] == 1
|
||||
assert status_data["pid"] is None
|
||||
assert any("docker pull nousresearch/hermes-agent:latest" in line for line in status_data["lines"])
|
||||
|
||||
def test_update_hermes_spawns_on_non_docker_install(self, monkeypatch):
|
||||
import hermes_cli.web_server as web_server
|
||||
|
||||
class Proc:
|
||||
pid = 12345
|
||||
|
||||
def poll(self):
|
||||
return None
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_spawn(subcommand, name):
|
||||
calls.append((subcommand, name))
|
||||
return Proc()
|
||||
|
||||
monkeypatch.setattr(web_server, "detect_install_method", lambda _root: "git")
|
||||
monkeypatch.setattr(web_server, "_spawn_hermes_action", fake_spawn)
|
||||
web_server._ACTION_PROCS.pop("hermes-update", None)
|
||||
web_server._ACTION_RESULTS.pop("hermes-update", None)
|
||||
|
||||
resp = self.client.post("/api/hermes/update")
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert resp.json() == {"ok": True, "pid": 12345, "name": "hermes-update"}
|
||||
assert calls == [(["update"], "hermes-update")]
|
||||
|
||||
def test_get_status_filters_unconfigured_gateway_platforms(self, monkeypatch):
|
||||
import gateway.config as gateway_config
|
||||
import hermes_cli.web_server as web_server
|
||||
|
||||
Reference in New Issue
Block a user