"""Unit tests for InputNode v1 — structured JSON analyst.""" from harness import HudCapture, make_envelope, make_history, NodeTestRunner from agent.nodes.input_v1 import InputNode async def test_greeting_is_social_trivial(): hud = HudCapture() node = InputNode(send_hud=hud) cmd = await node.process(make_envelope("hi there!"), [], memory_context="") assert cmd.analysis.intent == "social", f"intent={cmd.analysis.intent}" assert cmd.analysis.complexity == "trivial", f"complexity={cmd.analysis.complexity}" async def test_german_detected(): hud = HudCapture() node = InputNode(send_hud=hud) cmd = await node.process(make_envelope("Wie spaet ist es?"), [], memory_context="") assert cmd.analysis.language in ("de", "mixed"), f"language={cmd.analysis.language}" async def test_request_classified(): hud = HudCapture() node = InputNode(send_hud=hud) cmd = await node.process(make_envelope("create a counter with buttons"), [], memory_context="") assert cmd.analysis.intent in ("request", "action"), f"intent={cmd.analysis.intent}" assert cmd.analysis.complexity in ("simple", "complex"), f"complexity={cmd.analysis.complexity}" async def test_frustrated_tone(): hud = HudCapture() node = InputNode(send_hud=hud) cmd = await node.process(make_envelope("this is broken, nothing works and I'm sick of it"), [], memory_context="") assert cmd.analysis.tone in ("frustrated", "urgent"), f"tone={cmd.analysis.tone}" async def test_emits_perceived_hud(): hud = HudCapture() node = InputNode(send_hud=hud) await node.process(make_envelope("hello"), [], memory_context="") assert hud.has("perceived"), f"events: {[e.get('event') for e in hud.events]}" async def test_source_text_preserved(): hud = HudCapture() node = InputNode(send_hud=hud) cmd = await node.process(make_envelope("show me 5 customers"), [], memory_context="") assert cmd.source_text == "show me 5 customers", f"source_text={cmd.source_text}" if __name__ == "__main__": runner = NodeTestRunner() print("\n=== InputNode v1 ===") runner.test("greeting is social+trivial", test_greeting_is_social_trivial()) runner.test("german detected", test_german_detected()) runner.test("request classified", test_request_classified()) runner.test("frustrated tone", test_frustrated_tone()) runner.test("emits perceived HUD", test_emits_perceived_hud()) runner.test("source text preserved", test_source_text_preserved()) p, f = runner.summary() print(f"\n {p} passed, {f} failed")