Files
hermes-agent/tests/gateway/test_api_authority_execution.py
Teknium 707cf0fde0 test: gateway tests no longer seed fixture/ and owned/ Hermes homes into the checkout
A test authority with a symbolic profile_id ('owned', 'fixture', 'target', 'default', 'p') binds it
as a profile home; that is a RELATIVE path, so the first config load under it created
<cwd>/<id>/ with SOUL.md in the repo checkout, and fixture/SOUL.md + owned/SOUL.md got committed
(2cb67feb64). Production is unaffected: the only initialize_session_authority caller passes the
reserved absolute home.

- tests/conftest.py: autouse _checkout_home_guard skips any Hermes home initialization inside the
  checkout and fails the test at teardown (the scoped reads that hit it swallow their own errors),
  so the whole class is caught instead of discovered by git status.
- the 17 in-process offenders opt into the existing authority_cwd_in_tmp fixture; the 12
  subprocess peer tests run their child with cwd=tmp_path instead of the repo (PYTHONPATH already
  names the repo).
- git rm fixture/SOUL.md owned/SOUL.md.
2026-11-17 09:59:27 -08:00

30 lines
1.1 KiB
Python

"""API and authenticated WS share the existing selected cached agent."""
import json
import os
from pathlib import Path
import subprocess
import sys
def _probe(tmp_path, *, advanced=False, runs=False):
repo = Path(__file__).resolve().parents[2]
home, state = tmp_path / 'home', tmp_path / 'state'
home.mkdir()
state.mkdir()
env = {key: os.environ[key] for key in ('PATH', 'LANG', 'TZ', 'SYSTEMROOT') if key in os.environ}
env.update(HOME=str(home), USERPROFILE=str(home), HERMES_HOME=str(state), PYTHONPATH=str(repo))
if advanced:
env['API_ADVANCED'] = '1'
if runs:
env['API_RUN'] = str(runs)
result = subprocess.run([sys.executable, str(Path(__file__).parent / 'fixtures' / 'api_authority_peer.py')],
cwd=tmp_path, env=env, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=100, check=False)
assert result.returncode == 0, result.stdout + '\n' + result.stderr
receipt = json.loads((state / 'receipt.json').read_text())
assert receipt['same_agent'], receipt
print(json.dumps(receipt))
def test_api_and_ws_use_one_turnrunner(tmp_path):
_probe(tmp_path)