Systematic prune per AGENTS.md test policy, one pass over every major test tree (gateway, hermes_cli, tools, agent, run_agent, plugins, cli, cron, tui_gateway, honcho/openviking, root-level): - DELETE: source-reading tests (read_text/getsource on prod files), change-detector tests (exact catalog counts, model-name snapshots, config version literals), mock-echo tests (assert a mock returns what it was told), assertion-free/trivial tests, near-duplicate parametrizations (boundaries + one representative kept), async/sync twin duplicates, cosmetic within-file variations. - KEEP (mandatory): security/redaction/approval guards, message-role alternation invariants, prompt-caching/deterministic-call-id invariants, issue-number regression tests (deduped), E2E tests. - 6 test files deleted outright (script-style/no-assert or fully redundant); conftest.py, fakes/, fixtures/ untouched. - tests/acp/conftest.py added: autouse fixture stubs the live models.dev/GitHub/Copilot/Anthropic inventory fetches that ACP server tests performed on every session create — test_server.py 147s → 3.4s, and the tests are now genuinely hermetic. - Sleep-based slowness shrunk where safe (codex_ttfb_watchdog, compression_concurrent_fork, etc.); no wall-clock assertion tightened. Verification: full hermetic suite via scripts/run_tests.sh — 2439 files, 31,130 tests passed, 0 failed, 0 flaky retries, 315s wall (baseline: 583s wall, 13,564s subprocess CPU).
97 lines
2.7 KiB
Python
97 lines
2.7 KiB
Python
import argparse
|
|
import json
|
|
from types import SimpleNamespace
|
|
|
|
from hermes_cli import plugins_cmd
|
|
|
|
|
|
def _args(**kwargs):
|
|
defaults = {
|
|
"enabled": False,
|
|
"user": False,
|
|
"no_bundled": False,
|
|
"plain": False,
|
|
"json": False,
|
|
}
|
|
defaults.update(kwargs)
|
|
return argparse.Namespace(**defaults)
|
|
|
|
|
|
def test_filter_plugin_entries_enabled_only():
|
|
entries = [
|
|
("disk-cleanup", "2.0.0", "Bundled", "bundled", None, "disk-cleanup"),
|
|
("web-search-plus", "2.2.0", "Search", "git", None, "web-search-plus"),
|
|
("old-plugin", "1.0.0", "Old", "user", None, "old-plugin"),
|
|
]
|
|
|
|
filtered = plugins_cmd._filter_plugin_entries(
|
|
entries,
|
|
_args(enabled=True),
|
|
enabled={"disk-cleanup", "web-search-plus"},
|
|
disabled={"old-plugin"},
|
|
)
|
|
|
|
assert [entry[0] for entry in filtered] == ["disk-cleanup", "web-search-plus"]
|
|
|
|
|
|
def test_cmd_list_plain_compact_output(monkeypatch, capsys):
|
|
entries = [
|
|
("disk-cleanup", "2.0.0", "Bundled", "bundled", None, "disk-cleanup"),
|
|
("web-search-plus", "2.2.0", "Search", "git", None, "web-search-plus"),
|
|
]
|
|
monkeypatch.setattr(plugins_cmd, "_discover_all_plugins", lambda: entries)
|
|
monkeypatch.setattr(plugins_cmd, "_get_enabled_set", lambda: {"web-search-plus"})
|
|
monkeypatch.setattr(plugins_cmd, "_get_disabled_set", lambda: set())
|
|
|
|
plugins_cmd.cmd_list(_args(plain=True, no_bundled=True))
|
|
|
|
out = capsys.readouterr().out
|
|
assert "web-search-plus" in out
|
|
assert "enabled" in out
|
|
assert "disk-cleanup" not in out
|
|
assert "Search" not in out # plain mode stays compact, no descriptions
|
|
|
|
|
|
def test_discover_all_plugins_includes_entrypoint_plugins(monkeypatch, tmp_path):
|
|
bundled_dir = tmp_path / "bundled"
|
|
user_dir = tmp_path / "user"
|
|
bundled_dir.mkdir()
|
|
user_dir.mkdir()
|
|
|
|
dist = SimpleNamespace(
|
|
version="0.1.0",
|
|
metadata={"Summary": "Karpathy-style LLM Wikis for Hermes"},
|
|
)
|
|
entry_point = SimpleNamespace(
|
|
name="wiki",
|
|
value="adapters.hermes.cli_plugin",
|
|
group="hermes_agent.plugins",
|
|
dist=dist,
|
|
)
|
|
|
|
monkeypatch.setattr(plugins_cmd, "_plugins_dir", lambda: user_dir)
|
|
monkeypatch.setattr(
|
|
"hermes_cli.plugins.get_bundled_plugins_dir",
|
|
lambda: bundled_dir,
|
|
)
|
|
monkeypatch.setattr(
|
|
plugins_cmd.importlib.metadata,
|
|
"entry_points",
|
|
lambda: [entry_point],
|
|
)
|
|
|
|
entries = plugins_cmd._discover_all_plugins()
|
|
|
|
assert entries == [
|
|
(
|
|
"wiki",
|
|
"0.1.0",
|
|
"Karpathy-style LLM Wikis for Hermes",
|
|
"entrypoint",
|
|
"adapters.hermes.cli_plugin",
|
|
"wiki",
|
|
)
|
|
]
|
|
|
|
|