Files
hermes-agent/tests/gateway/test_api_authority_execution.py
Teknium e1a10b0bc2 ci: bring the branch's own code under main's strict ruff config
Main made the strict ruff config the default (`ruff check .`, blocking), and
the branch's code carried 278 findings under it (main itself is clean). Fixed:

- PLW1510 (86): `check=False` on each subprocess.run, preserving behaviour,
  as main's own sweep (0006a5e229) did.
- ASYNC220 (9, test fixtures only): `noqa` with the reason, main's convention
  for a Popen that returns at once and whose handle the test drives.
- ruff's safe autofixes plus the narrow unsafe ones (UP006/UP037/RUF100/RUF013/
  PLR0402/RUF059 underscore renames/UP031/UP041/UP017/FURB167/PIE807/RUF007/
  RUF015/RUF022/FURB162), and by hand: four %-formats to f-strings, three
  unused unpacked names, one fixture loop over `.items()`.

No behaviour change. `ruff check .` passes; scripts/check passes; the 412 test
files mirroring every edited file pass (3 tests/pm files that fail only under
that batch's uv lookup pass solo, before and after this commit).
2026-10-10 17:59:08 -07: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=repo, 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)