test_api_body.py 772 B

123456789101112131415161718192021222324
  1. """测试API返回的template_body"""
  2. import requests
  3. API_BASE = "http://localhost:8000/api"
  4. # 获取所有模板
  5. response = requests.get(f"{API_BASE}/templates")
  6. templates = response.json()
  7. print(f"总模板数: {len(templates)}")
  8. print()
  9. # 检查第一个模板
  10. if templates:
  11. tpl = templates[0]
  12. print(f"模板ID: {tpl.get('id')}")
  13. print(f"机型: {tpl.get('machine_model')}")
  14. print(f"类型: {tpl.get('template_type')}")
  15. print(f"has template_body: {'template_body' in tpl}")
  16. print(f"template_body类型: {type(tpl.get('template_body'))}")
  17. print(f"template_body长度: {len(str(tpl.get('template_body', '')))}")
  18. print()
  19. print("template_body前200字符:")
  20. print(str(tpl.get('template_body', ''))[:200])