diff options
| author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2026-11-23 21:33:28 +0200 |
|---|---|---|
| committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2026-12-01 23:02:47 +0200 |
| commit | ee5c222bf5d94fa993c44a6d0e1f53d82c962870 (patch) | |
| tree | f5cd62d3abedba3865ecffcad39a6a6f18876fc3 /xmpp-cli-bridge/tests/test_agent_wrapper.py | |
Diffstat (limited to 'xmpp-cli-bridge/tests/test_agent_wrapper.py')
| -rw-r--r-- | xmpp-cli-bridge/tests/test_agent_wrapper.py | 28 |
1 files changed, 28 insertions, 0 deletions
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 "<turn>(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" |
