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.
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user