46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from tests.harness.test_runner import TestCase
|
|
from .common import assert_success
|
|
|
|
SUITE = "test_conversation"
|
|
|
|
|
|
def _simple_greeting(ctx):
|
|
resp = ctx.client.prompt("Hello, what is your name?", max_turns=4)
|
|
assert_success(resp)
|
|
text = str(resp.get("final_response", "")).strip()
|
|
assert text, "empty final_response"
|
|
return True, "greeting response ok", {"response": text[:200]}
|
|
|
|
|
|
def _self_description(ctx):
|
|
resp = ctx.client.prompt("What are you? Describe yourself briefly.", max_turns=4)
|
|
assert_success(resp)
|
|
text = str(resp.get("final_response", "")).lower()
|
|
assert text, "empty final_response"
|
|
assert any(token in text for token in ["didactyl", "agent", "nostr"]), "response missing expected identity terms"
|
|
return True, "self description ok", {"response": text[:200]}
|
|
|
|
|
|
def _empty_message(ctx):
|
|
resp = ctx.client.prompt("", max_turns=2)
|
|
assert isinstance(resp, dict), "response should be JSON object"
|
|
return True, "empty message handled", {"success": resp.get("success")}
|
|
|
|
|
|
def _long_message(ctx):
|
|
long_msg = "A" * 10000
|
|
resp = ctx.client.prompt(long_msg, max_turns=4)
|
|
assert isinstance(resp, dict), "response should be JSON object"
|
|
return True, "long message handled", {"success": resp.get("success")}
|
|
|
|
|
|
def get_tests():
|
|
return [
|
|
TestCase(SUITE, "simple_greeting", "Simple hello prompt", _simple_greeting),
|
|
TestCase(SUITE, "agent_responds_about_itself", "Agent self description", _self_description),
|
|
TestCase(SUITE, "empty_message_handling", "Empty message behavior", _empty_message),
|
|
TestCase(SUITE, "very_long_message", "Very long input behavior", _long_message),
|
|
]
|