From 02b460a929da211d79fd058d3d5a55d33bf93198 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Mon, 14 Sep 2026 18:50:37 -0700 Subject: [PATCH] test(cli): neutralize the Windows supervisor scope in the no-gateways fleet-restart simulation too _run_pending_fleet_restart has three supervisor branches; #110709 covers launchd, this covers the Windows branch (gateway_windows.is_installed -> restart) so a Windows developer with an installed gateway service does not restart it from the test suite. --- tests/gateway/test_feishu.py | 11 ++++++----- tests/hermes_cli/test_update_fleet_restart_pending.py | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/gateway/test_feishu.py b/tests/gateway/test_feishu.py index 8612cd776d..b64b68d616 100644 --- a/tests/gateway/test_feishu.py +++ b/tests/gateway/test_feishu.py @@ -1709,11 +1709,12 @@ class TestDedupTTL(unittest.TestCase): from gateway.config import PlatformConfig from plugins.platforms.feishu.adapter import FeishuAdapter - # Keep the per-test HERMES_HOME through the env wipe: the adapter resolves its - # dedup store from get_hermes_home() at construction, and a cleared environment - # falls back to the operator's real ~/.hermes, whose live ids leak into writes[-1]. - with patch.dict(os.environ, {"HERMES_HOME": os.environ["HERMES_HOME"]}, clear=True): - adapter = FeishuAdapter(PlatformConfig()) + # The class-level env wipe drops the per-test HERMES_HOME, so the adapter resolves + # its dedup store under the operator's real ~/.hermes and every id a live gateway + # persisted leaks into writes[-1]. Pin the store to a scratch path instead. + with tempfile.TemporaryDirectory() as scratch: + with patch("plugins.platforms.feishu.adapter.get_hermes_home", return_value=Path(scratch)): + adapter = FeishuAdapter(PlatformConfig()) writes = [] calls = [0] diff --git a/tests/hermes_cli/test_update_fleet_restart_pending.py b/tests/hermes_cli/test_update_fleet_restart_pending.py index 103fedb847..e756b4edcf 100644 --- a/tests/hermes_cli/test_update_fleet_restart_pending.py +++ b/tests/hermes_cli/test_update_fleet_restart_pending.py @@ -359,6 +359,8 @@ def test_run_pending_restart_true_when_no_gateways(monkeypatch, capsys): monkeypatch.setattr( update_cmd_fleet, "_restart_macos_launchd_gateways", lambda *a, **k: None ) + # And the Windows scope: an installed Windows gateway service would be restarted for real. + monkeypatch.setattr("hermes_cli.gateway_windows.is_installed", lambda: False) assert update_cmd._run_pending_fleet_restart() is True assert "Pending fleet restart completed" in capsys.readouterr().out