`scripts/run_tests.sh tests/<dir>/` is how a change gets its regression
coverage run, so a test filed under the wrong directory is a test nobody
runs when that code changes. Two kinds of drift had accumulated.
Parallel directories for one source package, folded into the mirror:
tests/acp -> tests/acp_adapter (its __init__/conftest move with it)
tests/cli -> tests/hermes_cli (prompt_toolkit fixture merged into
hermes_cli/conftest.py)
tests/run_agent -> tests/agent (backoff fixture becomes
agent/conftest.py)
tests/relay -> tests/gateway/relay
tests/state -> tests/hermes_state
246 loose files at tests/ root, routed by the package they import/patch:
hermes_cli, hermes_state, agent, gateway, tools, plugins, tui_gateway, cron.
Installer and desktop-update script tests go to tests/scripts/{install,
desktop_update}/. 43 tests of root-level modules (batch_runner, utils,
hermes_constants, packaging) stay at the root.
Filenames drop their issue numbers (95 files: test_89315_x.py -> test_x.py);
the number stays in the module docstring where it has context.
Collisions: test_cli_skin_integration.py existed in both tests/ and tests/cli
with different subsets — merged into one (10 tests, all kept);
run_agent/test_pre_compress_memory_context.py -> agent/..._handoff.py;
tests/test_account_usage.py -> agent/test_account_usage_fetch.py;
tests/test_web_server.py -> hermes_cli/test_web_server_ws_ping.py.
Deleted: test_minisweagent_path.py (empty since PR #2804),
test_model_picker_scroll.py (tested a private copy of the logic, imported
nothing), test_process_loop_event_loop_warning.py (asserted asyncio behaviour,
imported nothing from Hermes).
Repo-root path arithmetic (Path(__file__).parents[N], dirname chains) is
bumped for the 202 files that changed depth and verified by evaluating every
such expression against the new location. classify_changes' desktop-updater
lane prefix, tests-os.yml's ignore glob and every in-tree path comment follow
the moves. tests/test_tests_tree_layout.py keeps the tree from drifting back.
63 lines
2.6 KiB
Python
63 lines
2.6 KiB
Python
"""Monitor navigation keeps controls pinned while live children finish."""
|
|
import asyncio
|
|
from types import SimpleNamespace
|
|
|
|
|
|
def test_monitor_keys_pin_controls_across_roster_changes(monkeypatch):
|
|
from hermes_cli.cli_subagent_monitor import SubagentMonitor, build_monitor_application
|
|
|
|
from prompt_toolkit.input import create_pipe_input
|
|
from prompt_toolkit.output import DummyOutput
|
|
from tools import delegate_tool_registry as registry
|
|
monkeypatch.setattr(registry, '_active_subagents', {})
|
|
received = []
|
|
child = SimpleNamespace(steer=lambda text: received.append(text) or True,
|
|
interrupt=lambda *a, **kw: received.append('STOP') or True)
|
|
for sid in ['first', 'second']:
|
|
registry._register_subagent(dict(subagent_id=sid, goal=sid, owner_agent_session_id='owner',
|
|
started_at=1, status='running', agent=child))
|
|
|
|
dock = SubagentMonitor(SimpleNamespace(agent=SimpleNamespace(session_id='owner')))
|
|
dock.refresh()
|
|
|
|
async def run():
|
|
with create_pipe_input() as pipe:
|
|
output = DummyOutput()
|
|
from prompt_toolkit.data_structures import Size
|
|
output.get_size = lambda: Size(rows=14, columns=32)
|
|
app = build_monitor_application(dock, input=pipe, output=output)
|
|
footer = app.layout.container.children[-1].content.text()
|
|
assert 'Ctrl+T' in footer and len(footer) <= 32
|
|
rendered = asyncio.Event()
|
|
app.after_render += lambda app: rendered.set()
|
|
task = asyncio.create_task(app.run_async())
|
|
await asyncio.wait_for(rendered.wait(), 3)
|
|
|
|
async def send(text):
|
|
rendered.clear()
|
|
pipe.send_text(text)
|
|
await asyncio.wait_for(rendered.wait(), 3)
|
|
|
|
await send('\x1b[B\rsFocus on tests\r')
|
|
await send('x')
|
|
registry._active_subagents.pop('second')
|
|
dock.refresh()
|
|
await send('y')
|
|
await send('\x1b')
|
|
pipe.send_text('\x14')
|
|
await asyncio.wait_for(task, 3)
|
|
asyncio.run(run())
|
|
assert dock.selected_id == 'first'
|
|
assert received == ['Focus on tests']
|
|
|
|
|
|
|
|
def test_extended_tail_is_bounded_and_literal(tmp_path):
|
|
from hermes_cli.cli_subagent_monitor import read_tail
|
|
path = tmp_path / 'child.log'
|
|
path.write_text('old data\n' * 20000 + '\x1b[2Jlast activity\n', encoding='utf-8')
|
|
tail = read_tail(str(path))
|
|
assert 'last activity' in tail and '\x1b' not in tail
|
|
assert len(tail) <= 32768
|
|
assert 'not available' in read_tail(str(tmp_path / 'missing.log'))
|