From ee5c222bf5d94fa993c44a6d0e1f53d82c962870 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Mon, 23 Nov 2026 21:33:28 +0200 Subject: initial commit --- xmpp-cli-bridge/tests/test_agent_wrapper.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 xmpp-cli-bridge/tests/test_agent_wrapper.py (limited to 'xmpp-cli-bridge/tests/test_agent_wrapper.py') diff --git a/xmpp-cli-bridge/tests/test_agent_wrapper.py b/xmpp-cli-bridge/tests/test_agent_wrapper.py new file mode 100644 index 0000000..c5cddc1 --- /dev/null +++ b/xmpp-cli-bridge/tests/test_agent_wrapper.py @@ -0,0 +1,28 @@ +"""Self-check for the coding-agent wrapper (no XMPP server needed).""" +from xmpp_cli_bridge.agent import PROMPT +from xmpp_cli_bridge.__main__ import make_handler + +# replicates agent.py's I/O shape: startup prompt, then "(N) > " +AGENT_LIKE = ( + "import sys\nsys.stdout.write('> ');sys.stdout.flush()\n" + "for line in sys.stdin:\n" + " sys.stdout.write('turn: ' + line + '(42) > ')\n" + " sys.stdout.flush()\n" +) + + +def test_prompt_matches_both_forms(): + assert PROMPT.search("reply text\n> ") + assert PROMPT.search("reply text\n(78412) > ") + # a reply merely containing '>' is not matched as the prompt + m = PROMPT.search("a > b\n> ") + assert m and m.end() == len("a > b\n> ") + + +def test_agent_like_roundtrip(): + h = make_handler( + ["python3", "-c", AGENT_LIKE], {"a@b"}, prompt=PROMPT, max_wait=5 + ) + # startup prompt drained, token-usage-style prompt stripped + assert h("list files", "a@b") == "turn: list files\n" + assert h("second", "a@b") == "turn: second\n" -- cgit v1.2.3