Files
hermes-agent/tests/gateway/test_pm_activation.py
ethernet 0b8aa8bf83 fix: align Python CI contracts with current PM and checkout behavior
Allow read-only merged-tag queries through the live-system guard, route checkpoint rekeying to its real ref-deletion owner, and update stale fixtures to exercise current update and PM boundaries. Fix the shutdown test wait by patching the bound server global.
2026-09-24 03:42:38 -04:00

31 lines
1014 B
Python

"""Gateway startup remains fail-open when PM admission itself fails.
Healthy/damaged real-store activation belongs to tests/pm/test_startup_activation.py.
"""
from unittest.mock import AsyncMock
import pytest
def test_gateway_main_survives_pm_failure(monkeypatch, tmp_path):
monkeypatch.setattr("pm.paths.install_root", lambda: tmp_path)
import pm
import gateway.run as gateway
failed = []
def broken():
failed.append("activate")
raise RuntimeError("PM unavailable")
monkeypatch.setattr(pm, "activate", broken)
started = AsyncMock(return_value=True)
exited = []
monkeypatch.setattr(gateway, "start_gateway", started)
monkeypatch.setattr(gateway, "_exit_after_graceful_shutdown", exited.append)
monkeypatch.setattr("hermes_cli.boot_bootstrap.maybe_run_boot_bootstrap", lambda root: None)
monkeypatch.setattr("sys.argv", ["gateway"])
gateway.main()
started.assert_awaited_once()
assert exited == [0]
assert failed == ["activate"]