test(update): autostash suite keeps the launchd restart scope off the host (#111866)

The autouse fixture neutralised gateway discovery and the systemd branch
but not the launchd one. On a macOS host `_restart_macos_launchd_gateways`
derives its labels from the profile layout, so a default profile alone
hands it `ai.hermes.gateway`, the label never "comes back", and nine
unrelated update tests exit 1 with "Update incomplete". No OS is faked:
the seam is stubbed the same way test_update_fleet_restart_pending does.
This commit is contained in:
teknium1
2026-09-15 20:04:55 -07:00
committed by Teknium
parent b7ccc82d82
commit f0fd0650b5
3 changed files with 179 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""The unmarked-macOS-fake guard (#111866): flags fakes, ignores honest reads and marked files."""
from __future__ import annotations
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "scripts" / "ci"))
from check_os_marker_fakes import find_unmarked_fakes # noqa: E402
def _write(root: Path, name: str, body: str) -> None:
(root / name).write_text(body, encoding="utf-8")
def test_unmarked_fake_is_flagged_marked_and_opted_out_are_not(tmp_path):
_write(tmp_path, "test_fake.py", "def test_x(monkeypatch):\n"
" monkeypatch.setattr(gw, 'is_macos', lambda: True)\n"
" monkeypatch.setattr(sys, 'platform', 'darwin')\n")
_write(tmp_path, "test_marked.py", "import pytest\npytestmark = pytest.mark.macos_only\n"
"def test_x(monkeypatch):\n monkeypatch.setattr(gw, 'is_macos', lambda: True)\n")
_write(tmp_path, "test_opted.py", "def test_x(monkeypatch):\n"
" patch('m.is_macos', return_value=True) # os-marker: ok — pure data mapping\n")
hits = find_unmarked_fakes(tmp_path, tmp_path)
assert set(hits) == {"test_fake.py"}
assert [n for n, _ in hits["test_fake.py"]] == [2, 3]
def test_host_honest_platform_read_is_not_a_fake(tmp_path):
_write(tmp_path, "test_read.py", "import sys\n"
"def test_x():\n expected = sys.platform == 'darwin'\n"
" if sys.platform == 'darwin':\n pass\n"
" payload = {'platform': 'darwin'}\n"
" # monkeypatch.setattr(gw, 'is_macos', lambda: True) in a comment\n")
assert find_unmarked_fakes(tmp_path, tmp_path) == {}
@@ -57,9 +57,14 @@ def _patch_gateway_discovery():
phase's fresh ``from hermes_cli.gateway import ...`` then loads an
UNPATCHED copy of the module — silently discarding every mock here and
letting real gateway discovery (and real ``os.kill``) run on the dev box.
The launchd scope is neutralised too: on a macOS host the restart phase
derives labels from the profile layout, so a default profile alone hands
it ``ai.hermes.gateway`` and the verify step exits 1 (#111866, #110701).
"""
with patch("hermes_cli.gateway.find_gateway_pids", return_value=[]), \
patch("hermes_cli.gateway.supports_systemd_services", return_value=False), \
patch("hermes_cli.update_cmd_fleet._restart_macos_launchd_gateways", lambda *a, **k: None), \
patch("hermes_cli.gateway.find_profile_gateway_processes", return_value=[]), \
patch("hermes_cli.update_inventory.collect_runtime_inventory", return_value=None), \
patch("hermes_cli.update_inventory.report_unaccounted_runtimes", return_value=False), \