| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #!/usr/bin/env python3
- """
- 测试心跳API是否正确返回配置信息
- """
- import requests
- import json
- import time
- def test_heartbeat_config():
- """测试心跳API返回配置信息"""
- print("🧪 测试心跳API配置更新功能")
- # 模拟登录获取session_id(这里需要先登录获取真实session_id)
- # 由于没有真实登录,这里只是展示API结构
- print("📝 心跳API响应结构示例:")
- example_response = {
- "code": 200,
- "msg": "成功",
- "data": {
- "expire_time": "2026-12-31T23:59:59",
- "server_time": "2026-01-06T17:23:25.000000",
- "session_status": "active",
- "next_heartbeat": 30,
- "session_expires_at": "2026-01-07T17:23:25.000000",
- "session_extend_enabled": True,
- "session_extend_threshold_hours": 4,
- "client_configs": {
- "api_timeout_seconds": 30,
- "client_heartbeat_interval_seconds": 30,
- "max_heartbeat_failures": 10,
- "max_network_failures": 15
- }
- },
- "timestamp": int(time.time())
- }
- print(json.dumps(example_response, indent=2, ensure_ascii=False))
- print("\n✅ 心跳API现在会返回以下配置信息:")
- print(" - api_timeout_seconds: API请求超时秒数")
- print(" - client_heartbeat_interval_seconds: 客户端心跳间隔秒数")
- print(" - max_heartbeat_failures: 最大心跳失败次数")
- print(" - max_network_failures: 网络异常最大失败次数")
- print("\n🔄 客户端会在每次心跳时自动更新这些配置,无需重启应用")
- if __name__ == "__main__":
- test_heartbeat_config()
|