From 2eab04fd84de171f245f6d4c09411cd8e863e43d Mon Sep 17 00:00:00 2001 From: Tranquil-Flow Date: Sat, 25 Apr 2026 08:53:10 +1000 Subject: [PATCH] fix(cli): mock systemd preflight in gateway service tests for non-systemd environments (#15187) Mock _preflight_user_systemd and _select_systemd_scope in test_systemd_start_refreshes_outdated_unit and test_systemd_restart_refreshes_outdated_unit. These tests target unit-file refresh logic, not D-Bus reachability, so the preflight check was causing spurious UserSystemdUnavailableError on macOS, WSL, and Docker where systemd is unavailable. --- tests/hermes_cli/test_gateway_service.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/hermes_cli/test_gateway_service.py b/tests/hermes_cli/test_gateway_service.py index bd429bff2b..75a0839ebb 100644 --- a/tests/hermes_cli/test_gateway_service.py +++ b/tests/hermes_cli/test_gateway_service.py @@ -44,6 +44,10 @@ class TestSystemdServiceRefresh: monkeypatch.setattr(gateway_cli, "get_systemd_unit_path", lambda system=False: unit_path) monkeypatch.setattr(gateway_cli, "generate_systemd_unit", lambda system=False, run_as_user=None: "new unit\n") + # Bypass systemd availability checks — this test targets unit-file + # refresh logic, not D-Bus reachability (fails on macOS/WSL/Docker). + monkeypatch.setattr(gateway_cli, "_preflight_user_systemd", lambda **kw: None) + monkeypatch.setattr(gateway_cli, "_select_systemd_scope", lambda system=False: False) calls = [] @@ -67,6 +71,10 @@ class TestSystemdServiceRefresh: monkeypatch.setattr(gateway_cli, "get_systemd_unit_path", lambda system=False: unit_path) monkeypatch.setattr(gateway_cli, "generate_systemd_unit", lambda system=False, run_as_user=None: "new unit\n") + # Bypass systemd availability checks — this test targets unit-file + # refresh logic, not D-Bus reachability (fails on macOS/WSL/Docker). + monkeypatch.setattr(gateway_cli, "_preflight_user_systemd", lambda **kw: None) + monkeypatch.setattr(gateway_cli, "_select_systemd_scope", lambda system=False: False) calls = []