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