Skip to content

The agent that grows with you

test(update): mock gateway discovery now that the restart phase is surfaced

Tekniumcd34661e9ccf
diff --git a/tests/hermes_cli/test_cmd_update.py b/tests/hermes_cli/test_cmd_update.py
index 8c055969b94..5badf692133 100644
--- a/tests/hermes_cli/test_cmd_update.py
+++ b/tests/hermes_cli/test_cmd_update.py
@@ -71,6 +71,24 @@ def _patch_managed_uv(request):
yield
[email protected](autouse=True)
+def _patch_gateway_discovery():
+ """Keep cmd_update's gateway auto-restart phase off this machine's gateways.
+
+ The restart phase used to swallow every exception at debug level, so these
+ end-to-end tests never noticed it touching real gateway discovery. Since
+ the phase is surfaced (#78574: an aborted restart now fails the update),
+ an unmocked ``find_gateway_pids`` on a box with a live gateway reaches the
+ conftest live-system guard and turns into a spurious ``sys.exit(1)``.
+ Discovery returning nothing makes the phase a clean no-op for every test
+ in this module (none of them assert on gateway restarts).
+ """
+ with patch("hermes_cli.gateway.find_gateway_pids", return_value=[]), \
+ patch("hermes_cli.gateway.supports_systemd_services", return_value=False), \
+ patch("hermes_cli.gateway.find_profile_gateway_processes", return_value=[]):
+ yield
+
+
class TestCmdUpdateNpmLockfileCache:
@staticmethod
def _cache_file(hermes_root, project_root):
diff --git a/tests/hermes_cli/test_update_head_moved_gate.py b/tests/hermes_cli/test_update_head_moved_gate.py
index ea8daa5d854..f363dac4117 100644
--- a/tests/hermes_cli/test_update_head_moved_gate.py
+++ b/tests/hermes_cli/test_update_head_moved_gate.py
@@ -105,6 +105,20 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect):
monkeypatch.setattr(hermes_main, "_clear_update_incomplete_marker", lambda: None)
# Gateway restart path (called after a successful update).
monkeypatch.setattr(hermes_main, "_finish_dashboard_update_cleanup", lambda *a: None)
+ # Keep the (now surfaced — #78574) gateway auto-restart phase away from
+ # this machine's real gateways: discovery returns nothing, systemd is
+ # unsupported, so the phase is a clean no-op for both snapshots.
+ import hermes_cli.gateway as hermes_gateway
+
+ monkeypatch.setattr(
+ hermes_gateway, "find_gateway_pids", lambda all_profiles=False: []
+ )
+ monkeypatch.setattr(
+ hermes_gateway, "supports_systemd_services", lambda: False
+ )
+ monkeypatch.setattr(
+ hermes_gateway, "find_profile_gateway_processes", lambda *a, **k: []
+ )
def test_update_success_when_head_moves(monkeypatch, tmp_path, capsys):