Files
hermes-agent/tests/tools/test_annotate_preview_tool.py
teknium1 524c38a98a test: purge low-value tests, lane py16 (624 removed)
Change-detectors, tautologies, source-reading tests, redundant duplicates,
mock-echo tests and dead/unrunnable tests. Per-test rationale in the lane
ledger (category + reason for every removal).
2026-09-23 03:15:26 -07:00

77 lines
2.1 KiB
Python

"""Tests for the GUI-surface ``annotate_preview`` tool."""
import json
import pytest
from tools import annotate_preview_tool as an
from tools.registry import registry
def test_lives_in_the_gui_surface_toolset(monkeypatch):
"""Scoped by toolset, not by the backend's env — same as its siblings."""
monkeypatch.delenv("HERMES_DESKTOP", raising=False)
entry = registry.get_entry("annotate_preview")
assert entry is not None
assert entry.toolset == "desktop_ui"
assert entry.check_fn is None
def test_requires_callback():
result = json.loads(an.annotate_preview_tool(ref="@e1", callback=None))
assert "desktop" in result["error"]
@pytest.mark.parametrize("verb", ["add", "remove"])
def test_marking_one_thing_needs_a_target(verb):
"""A mark with nothing to attach to is a mistake worth naming early."""
result = json.loads(an.annotate_preview_tool(action=verb, callback=lambda _p: "{}"))
assert "ref" in result["error"]
def test_speaks_the_renderer_s_verbs():
"""The overlay knows pin/unpin; the model gets words it can guess at."""
sent = []
def cb(payload):
sent.append(payload)
return json.dumps({"acted": "pinned Buy now", "success": True})
an.annotate_preview_tool(action="add", ref="@e4", label="cheapest", callback=cb)
an.annotate_preview_tool(action="remove", ref="@e4", callback=cb)
assert sent[0] == {"action": "pin", "ref": "@e4", "text": "cheapest"}
assert sent[1] == {"action": "unpin", "ref": "@e4"}
def test_clear_sends_no_target_so_the_overlay_drops_them_all():
"""`clear` IS an untargeted unpin — a ref left on it would take down one."""
sent = []
def cb(payload):
sent.append(payload)
return json.dumps({"acted": "cleared every pin", "success": True})
an.annotate_preview_tool(action="clear", ref="@e4", selector="a", callback=cb)
assert sent == [{"action": "unpin"}]
def test_defaults_to_adding():
sent = []
def cb(payload):
sent.append(payload)
return json.dumps({"success": True})
an.annotate_preview_tool(ref="@e2", callback=cb)
assert sent[0]["action"] == "pin"