-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_package.py
More file actions
112 lines (93 loc) · 3.46 KB
/
Copy pathtest_package.py
File metadata and controls
112 lines (93 loc) · 3.46 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
#!/usr/bin/env python3
"""
Test script to verify AGT Server package installation
Run this script to test if the package was installed correctly
and all imports work as expected.
"""
import sys
import importlib
def test_import(module_name, description):
"""Test if a module can be imported."""
try:
module = importlib.import_module(module_name)
print(f"✓ {description}: {module_name}")
return True
except ImportError as e:
print(f"✗ {description}: {module_name} - {e}")
return False
def test_class_import(module_name, class_name, description):
"""Test if a specific class can be imported from a module."""
try:
module = importlib.import_module(module_name)
if hasattr(module, class_name):
print(f"✓ {description}: {class_name} from {module_name}")
return True
else:
print(f"✗ {description}: {class_name} not found in {module_name}")
return False
except ImportError as e:
print(f"✗ {description}: {module_name} - {e}")
return False
def main():
"""Run all package tests."""
print("AGT Server Package Test")
print("=" * 30)
tests_passed = 0
total_tests = 0
# Test basic package import
total_tests += 1
if test_import("agt_server", "Main package"):
tests_passed += 1
# Test main server class
total_tests += 1
if test_class_import("agt_server", "AGTServer", "Main server class"):
tests_passed += 1
# Test game engine
total_tests += 1
if test_class_import("agt_server", "GameEngine", "Game engine"):
tests_passed += 1
# Test individual game classes
game_classes = [
("RPSGame", "Rock Paper Scissors game"),
("BOSGame", "Battle of the Sexes game"),
("ChickenGame", "Chicken game"),
("PDGame", "Prisoner's Dilemma game"),
("LemonadeGame", "Lemonade Stand game"),
("AuctionGame", "Auction game")
]
for class_name, description in game_classes:
total_tests += 1
if test_class_import("agt_server", class_name, description):
tests_passed += 1
# Test CLI module
total_tests += 1
if test_import("agt_server.cli", "CLI module"):
tests_passed += 1
# Test server module
total_tests += 1
if test_import("agt_server.server.server", "Server module"):
tests_passed += 1
# Test dashboard module
total_tests += 1
if test_import("agt_server.dashboard.app", "Dashboard module"):
tests_passed += 1
# Test core modules
total_tests += 1
if test_import("agt_server.core.engine", "Core engine"):
tests_passed += 1
# Summary
print("\n" + "=" * 30)
print(f"Test Results: {tests_passed}/{total_tests} tests passed")
if tests_passed == total_tests:
print("🎉 All tests passed! Package is working correctly.")
print("\nYou can now use:")
print(" agt-server --help")
print(" agt-dashboard --help")
print(" python -m agt_server.cli both")
else:
print("⚠ Some tests failed. Please check the errors above.")
print("You may need to reinstall the package or check dependencies.")
return tests_passed == total_tests
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)