"""仅验证合成的渠道变更响应，不调用网络，不修改网关。"""
import json

cases = [
    {"id": "text-1", "kind": "text", "result": "完成的示例文本", "complete": True},
    {"id": "json-1", "kind": "json", "result": '{"amount":"12.00"}', "complete": True},
    {"id": "stream-1", "kind": "text", "result": "收到部分内容", "complete": False},
]
failed = []
for case in cases:
    reasons = []
    if not case["complete"]:
        reasons.append("completion_missing")
    if not case["result"].strip():
        reasons.append("empty")
    if case["kind"] == "json":
        try:
            result = json.loads(case["result"])
            if not isinstance(result, dict) or not isinstance(result.get("order_id"), str) or not result["order_id"]:
                reasons.append("order_id_missing")
        except (json.JSONDecodeError, TypeError):
            reasons.append("invalid_json")
    print(case["id"], ",".join(reasons) if reasons else "pass")
    if reasons:
        failed.append(case["id"])
assert failed == ["json-1", "stream-1"]
print("hold")
