SPB Git

spb/wp29_uqo

Public
769 B · 12 lines python
1import os, sys, json2sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "src"))3from pgar.events import normalise, parse_result_line45def test_normalise_types():6    line = json.dumps({"type": "assistant", "session_id": "s", "message": {"content": [{"type": "tool_use", "name": "Bash", "input": {"command": "ls"}}], "usage": {"input_tokens": 10}}})7    ev = normalise(line, "R1", 3, 1.5)8    assert ev["event_type"] == "assistant" and ev["tool_name"] == "Bash" and ev["event_id"] == "R1:00003"9    res = json.dumps({"type": "result", "subtype": "success", "total_cost_usd": 0.5, "num_turns": 4, "session_id": "s"})10    assert parse_result_line(res)["total_cost_usd"] == 0.511    assert normalise("not json", "R1", 4, 2.0)["event_type"] == "unparsed"12
Files · 32c4ccff60dd76c81da4f5b63d24bd0b55824e43
Menu

Theme