6b81590c55
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).
68 lines
2.6 KiB
Python
68 lines
2.6 KiB
Python
"""Tests for the shared session-listing helpers (hermes_cli/session_listing.py)."""
|
|
|
|
import pytest
|
|
|
|
from hermes_cli.session_listing import (
|
|
parse_session_listing_args,
|
|
query_session_listing,
|
|
)
|
|
|
|
|
|
class TestParseSessionListingArgs:
|
|
def test_plain_listing(self):
|
|
assert parse_session_listing_args("") == (False, False, "", None)
|
|
|
|
|
|
def test_search_word_inside_target_is_not_a_flag(self):
|
|
# Flags/keywords only apply before the first positional word.
|
|
assert parse_session_listing_args("deep search notes") == (
|
|
False, False, "deep search notes", None,
|
|
)
|
|
|
|
|
|
class TestQuerySessionListingSearch:
|
|
@pytest.fixture
|
|
def db(self, tmp_path):
|
|
from hermes_state import SessionDB
|
|
db = SessionDB(db_path=tmp_path / "state.db")
|
|
db.create_session("sess_an94", "telegram", user_id="1", chat_id="2")
|
|
db.set_session_title("sess_an94", "AN-94 Prestige Barrel Build #2")
|
|
db.create_session("sess_winton", "whatsapp", user_id="1", chat_id="2")
|
|
db.set_session_title("sess_winton", "Winton Email Sheet Update #3")
|
|
db.create_session("sess_untitled", "telegram", user_id="1", chat_id="2")
|
|
yield db
|
|
db.close()
|
|
|
|
def _ids(self, db, **kw):
|
|
return [r["id"] for r in query_session_listing(db, **kw)]
|
|
|
|
def test_title_substring_match(self, db):
|
|
assert self._ids(db, source="telegram", search_query="prestige") == ["sess_an94"]
|
|
|
|
|
|
def test_source_scoping(self, db):
|
|
assert self._ids(db, source="telegram", search_query="winton") == []
|
|
assert self._ids(db, source="whatsapp", search_query="winton") == ["sess_winton"]
|
|
|
|
|
|
def test_search_matches_compression_root_title(self, tmp_path):
|
|
"""Searching an old (compressed-away) title surfaces the live tip."""
|
|
from hermes_state import SessionDB
|
|
db = SessionDB(db_path=tmp_path / "chain.db")
|
|
db.create_session("root_1", "telegram", user_id="1", chat_id="2")
|
|
db.set_session_title("root_1", "Old Chat")
|
|
db.end_session("root_1", end_reason="compression")
|
|
db.create_session(
|
|
"tip_1", "telegram", user_id="1", chat_id="2", parent_session_id="root_1"
|
|
)
|
|
db.set_session_title("tip_1", "AN-94 Build")
|
|
try:
|
|
for query in ("old chat", "root_1", "an94"):
|
|
rows = query_session_listing(db, source="telegram", search_query=query)
|
|
assert [r["id"] for r in rows] == ["tip_1"], query
|
|
finally:
|
|
db.close()
|
|
|
|
def test_plain_listing_still_hides_unnamed(self, db):
|
|
assert self._ids(db, source="telegram") == ["sess_an94"]
|