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).
38 lines
1.8 KiB
Python
38 lines
1.8 KiB
Python
"""Clarification response survives viewer detach through the real gateway worker."""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def test_real_shared_clarify_survives_detach(tmp_path):
|
|
home, state = tmp_path / 'home', tmp_path / 'state'
|
|
home.mkdir()
|
|
state.mkdir()
|
|
repo = Path(__file__).resolve().parents[2]
|
|
env = {key: os.environ[key] for key in ('PATH', 'LANG', 'TZ') if key in os.environ}
|
|
env.update(HOME=str(home), USERPROFILE=str(home), HERMES_HOME=str(state), PYTHONPATH=str(repo))
|
|
result = subprocess.run(
|
|
[sys.executable, str(Path(__file__).parent / 'fixtures' / 'authority_clarify_peer.py')],
|
|
cwd=repo, env=env, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=60, check=False)
|
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
assert (state / 'clarify-passed').read_text() == 'reply reached real model; stale reply rejected'
|
|
|
|
|
|
def test_expired_clarify_disappears_before_turn_settlement():
|
|
from gateway.session_events import SessionEvents
|
|
from gateway.session_pending_controls import PendingControls
|
|
from tools import clarify_gateway
|
|
|
|
events = SessionEvents()
|
|
controls = PendingControls(events)
|
|
entry = clarify_gateway.register('owned-expiring-question', 'owned-expiring-route', 'Choose', ['a', 'b'])
|
|
try:
|
|
controls.register_clarify('owned-session', 1, entry)
|
|
assert controls.snapshot('owned-session', 1)
|
|
assert clarify_gateway.wait_for_response(entry.clarify_id, timeout=.01) is None
|
|
assert controls.snapshot('owned-session', 1) == ()
|
|
assert controls.respond('owned-session', 1, entry.clarify_id, {'answer': 'a'}, kind='clarify')['status'] == 'already_resolved'
|
|
finally:
|
|
clarify_gateway.clear_session(entry.session_key)
|