-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli.py
More file actions
126 lines (107 loc) · 3.24 KB
/
test_cli.py
File metadata and controls
126 lines (107 loc) · 3.24 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
"""
测试命令行工具是否正常工作
"""
import subprocess
import sys
def test_help():
"""测试 help 命令"""
print("测试 1: openspace-evolution --help")
result = subprocess.run(
[sys.executable, "-m", "openspace_openhands_evolution", "--help"],
capture_output=True,
text=True
)
if result.returncode == 0 and "OpenSpace-OpenHands-Evolution" in result.stdout:
print("✅ PASS\n")
return True
else:
print("❌ FAIL")
print(result.stderr)
return False
def test_version():
"""测试版本信息"""
print("测试 2: 检查包版本")
try:
from openspace_openhands_evolution import __version__
print(f" 版本: {__version__}")
print("✅ PASS\n")
return True
except Exception as e:
print(f"❌ FAIL: {e}\n")
return False
def test_import():
"""测试导入"""
print("测试 3: 导入核心模块")
try:
from openspace_openhands_evolution import (
EvolutionOrchestrator,
TaskRequest,
TransferRequest,
load_config
)
print(" ✅ EvolutionOrchestrator")
print(" ✅ TaskRequest")
print(" ✅ TransferRequest")
print(" ✅ load_config")
print("✅ PASS\n")
return True
except Exception as e:
print(f"❌ FAIL: {e}\n")
return False
def test_config():
"""测试配置加载"""
print("测试 4: 配置加载")
try:
from openspace_openhands_evolution import load_config
config = load_config()
if 'openspace' in config and 'openhands' in config:
print(" ✅ 配置结构正确")
print(f" - OpenSpace registry: {config['openspace']['registry_path']}")
print(f" - OpenHands model: {config['openhands']['model']}")
print("✅ PASS\n")
return True
else:
print("❌ FAIL: 配置结构错误\n")
return False
except Exception as e:
print(f"❌ FAIL: {e}\n")
return False
def main():
"""运行所有测试"""
print("="*60)
print(" 🔧 OpenSpace-OpenHands-Evolution 测试")
print("="*60)
print()
tests = [
test_import,
test_version,
test_config,
test_help,
]
results = []
for test in tests:
try:
results.append(test())
except Exception as e:
print(f"❌ 测试异常: {e}\n")
results.append(False)
# 总结
print("="*60)
passed = sum(results)
total = len(results)
if passed == total:
print(f" 🎉 所有测试通过! ({passed}/{total})")
print("="*60)
print("\n✨ 项目已准备就绪!")
print("\n现在可以使用:")
print(" openspace-evolution # 交互模式")
print(" openspace-evolution run \"创建 API\" # 执行任务")
print(" openspace-evolution status # 查看状态")
return 0
else:
print(f" ⚠️ {passed}/{total} 个测试通过")
print("="*60)
return 1
if __name__ == "__main__":
sys.exit(main())