generated from coulomb/repo-seed
Implement llm-connect ADHOC diagnostics
This commit is contained in:
62
tests/test_replay.py
Normal file
62
tests/test_replay.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from llm_connect.replay import parse_audit_record
|
||||
|
||||
|
||||
STRUCTURED_SCHEMA = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"summary": {"type": "string"},
|
||||
"recommendations": {"type": "array", "items": {"type": "string"}},
|
||||
},
|
||||
"required": ["summary", "recommendations"],
|
||||
}
|
||||
|
||||
|
||||
def test_replay_parses_openai_style_provider_response():
|
||||
record = {
|
||||
"provider": "openrouter",
|
||||
"config": {"model_params": {"json_schema": STRUCTURED_SCHEMA}},
|
||||
"provider_response": {
|
||||
"status": 200,
|
||||
"body": {
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
"content": '{"summary":"ok","recommendations":[]}'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
"parsed_content": '{"summary":"ok","recommendations":[]}',
|
||||
}
|
||||
|
||||
report = parse_audit_record(record)
|
||||
|
||||
assert report["parsed_content"] == '{"summary":"ok","recommendations":[]}'
|
||||
assert report["matches_recorded_content"] is True
|
||||
assert report["structured_output"] == {"checked": True, "valid": True}
|
||||
|
||||
|
||||
def test_replay_reuses_claude_code_envelope_unwrapper():
|
||||
record = {
|
||||
"provider": "claude-code",
|
||||
"config": {"model_params": {"json_schema": STRUCTURED_SCHEMA}},
|
||||
"provider_response": {
|
||||
"status": 0,
|
||||
"body": {
|
||||
"stdout": (
|
||||
'{"type":"result","result":"prose",'
|
||||
'"structured_result":"{\\"summary\\":\\"ok\\",'
|
||||
'\\"recommendations\\":[]}"}'
|
||||
),
|
||||
"stderr": "",
|
||||
},
|
||||
},
|
||||
"parsed_content": '{"summary":"ok","recommendations":[]}',
|
||||
}
|
||||
|
||||
report = parse_audit_record(record)
|
||||
|
||||
assert report["parsed_content"] == '{"summary":"ok","recommendations":[]}'
|
||||
assert report["matches_recorded_content"] is True
|
||||
assert report["structured_output"] == {"checked": True, "valid": True}
|
||||
Reference in New Issue
Block a user