-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
74 lines (57 loc) · 1.97 KB
/
test_app.py
File metadata and controls
74 lines (57 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""
AgentCalendar 应用测试脚本
快速测试前后端服务是否正常工作
"""
import requests
import sys
def test_backend():
"""测试后端API"""
try:
# 测试根路径
response = requests.get("http://localhost:8000/", timeout=5)
print(f"✅ 后端根路径: {response.status_code} - {response.json()}")
# 测试API文档
response = requests.get("http://localhost:8000/docs", timeout=5)
print(f"✅ API文档: {response.status_code}")
# 测试获取事件
response = requests.get("http://localhost:8000/api/v1/events", timeout=5)
print(f"✅ 事件API: {response.status_code} - 数据量: {len(response.json())}")
return True
except Exception as e:
print(f"❌ 后端测试失败: {e}")
return False
def test_frontend():
"""测试前端服务"""
try:
response = requests.get("http://localhost:3000/", timeout=5)
print(f"✅ 前端服务: {response.status_code}")
return True
except Exception as e:
print(f"❌ 前端测试失败: {e}")
return False
def main():
print("🧪 AgentCalendar 服务测试")
print("=" * 40)
print("\n1. 测试后端服务 (localhost:8000)...")
if test_backend():
print("✅ 后端服务正常")
else:
print("❌ 后端服务异常")
return
print("\n2. 测试前端服务 (localhost:3000)...")
if test_frontend():
print("✅ 前端服务正常")
else:
print("❌ 前端服务异常")
return
print("\n🎉 所有服务运行正常!")
print("- 前端界面: http://localhost:3000")
print("- API文档: http://localhost:8000/docs")
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "--help":
print("用法:")
print(" python test_app.py # 测试服务")
print(" python test_app.py --help # 显示帮助")
sys.exit(0)
main()