From cd34661e9ccfd9175651d42bb7efe1798a4db4bf Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 14 Aug 2026 21:06:00 -0700 Subject: [PATCH] test(update): mock gateway discovery now that the restart phase is surfaced The gateway auto-restart phase used to swallow every exception at debug level, so tests driving cmd_update end-to-end never noticed it touching real gateway discovery. With #78574 surfacing an aborted restart as a failed update, an unmocked find_gateway_pids on a box with a live gateway hits the conftest live-system guard and turns into a spurious sys.exit(1). Add an autouse fixture in test_cmd_update.py (discovery returns nothing, systemd unsupported) and the same seams in test_update_head_moved_gate's helper so the phase is a clean no-op for tests that do not assert on gateway restarts. --- tests/hermes_cli/test_cmd_update.py | 18 ++++++++++++++++++ .../hermes_cli/test_update_head_moved_gate.py | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/hermes_cli/test_cmd_update.py b/tests/hermes_cli/test_cmd_update.py index 8c055969b9..5badf69213 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 +@pytest.fixture(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 ea8daa5d85..f363dac411 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):