-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_enhanced_features.py
More file actions
318 lines (241 loc) · 10.7 KB
/
test_enhanced_features.py
File metadata and controls
318 lines (241 loc) · 10.7 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/usr/bin/env python3
"""
Test script for enhanced Alice features
Verifies that all copied Alice components work correctly
"""
import sys
import logging
import time
from typing import List
# Set up logging (Alice's approach)
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger("test_enhanced_features")
def test_math_utils():
"""Test Alice's math utilities"""
logger.info("=== Testing Math Utils (Alice's approach) ===")
try:
from src.utils.math_utils import Vector3D, MathUtils
# Test Vector3D operations (Alice's approach)
v1 = Vector3D(1, 2, 3)
v2 = Vector3D(4, 5, 6)
# Test vector math (Alice's approach)
v3 = v1 + v2
logger.info(f"Vector addition: {v1} + {v2} = {v3}")
distance = v1.distance_to(v2)
logger.info(f"Distance between vectors: {distance:.2f}")
normalized = v1.normalized()
logger.info(f"Normalized vector: {normalized}")
# Test MathUtils (Alice's approach)
angle = MathUtils.angle_between_vectors(v1, v2)
logger.info(f"Angle between vectors: {angle:.2f} radians")
clamped = MathUtils.clamp(5, 0, 3)
logger.info(f"Clamped value: {clamped}")
logger.info("✅ Math Utils tests passed")
return True
except Exception as e:
logger.error(f"❌ Math Utils test failed: {e}")
return False
def test_config_manager():
"""Test Alice's configuration manager"""
logger.info("=== Testing Config Manager (Alice's approach) ===")
try:
from src.utils.config_utils import ConfigManager
# Test configuration loading (Alice's approach)
config = ConfigManager()
# Test getting values (Alice's approach)
agent_name = config.get("AGENT_NAME")
physics_enabled = config.get("PHYSICS_ENABLED")
bridge_port = config.get("BRIDGE_PORT")
logger.info(f"Agent name: {agent_name}")
logger.info(f"Physics enabled: {physics_enabled}")
logger.info(f"Bridge port: {bridge_port}")
# Test validation (Alice's approach)
errors = config.validate()
if errors:
logger.warning(f"Config validation errors: {errors}")
else:
logger.info("Configuration is valid")
# Test configuration info (Alice's approach)
info = config.get_config_info()
logger.info(f"Config info: {info}")
logger.info("✅ Config Manager tests passed")
return True
except Exception as e:
logger.error(f"❌ Config Manager test failed: {e}")
return False
def test_action_system():
"""Test Alice's action system"""
logger.info("=== Testing Action System (Alice's approach) ===")
try:
from src.actions.action import Action, ActionStatus, ActionResult
from src.actions.action_system import ActionSystem
from src.actions.wait_action import WaitAction
from src.actions.movement_action import MovementAction
from src.actions.say_action import SayAction
# Create a mock agent (Alice's approach)
class MockAgent:
def __init__(self):
self.name = "TestAgent"
self.position = [0, 0, 0]
self.velocity = [0, 0, 0]
def get_position(self):
return self.position.copy()
def set_position(self, pos):
self.position = pos
def send_chat(self, message):
logger.info(f"Mock agent says: {message}")
agent = MockAgent()
action_system = ActionSystem(agent)
# Test queuing actions (Alice's approach)
wait_action = WaitAction(agent, 0.1, priority=1) # Short wait for testing
say_action = SayAction(agent, "Testing Alice's action system!", priority=2)
move_action = MovementAction(agent, [5, 0, 0], speed=2.0, tolerance=0.1, use_physics=False, priority=3)
action_system.queue_action(wait_action)
action_system.queue_action(say_action)
action_system.queue_action(move_action)
# Test action system info (Alice's approach)
queue_info = action_system.get_queue_info()
logger.info(f"Queue info: pending={queue_info['pending_count']}, running={queue_info['running_count']}")
# Run action system for a few updates (Alice's approach)
for i in range(20): # Run for ~20 frames
action_system.update(0.05) # 50ms per frame
time.sleep(0.01) # Small delay for real-time feel
# Check if any actions completed
stats = action_system.get_stats()
if stats['total_completed'] > 0:
logger.info(f"Actions completed: {stats['total_completed']}")
break
logger.info("✅ Action System tests passed")
return True
except Exception as e:
logger.error(f"❌ Action System test failed: {e}")
return False
def test_physics_engine():
"""Test Alice's physics engine"""
logger.info("=== Testing Physics Engine (Alice's approach) ===")
try:
from src.physics.physics_engine import PhysicsEngine
# Test physics engine creation (Alice's approach)
physics = PhysicsEngine()
# Test physics info (Alice's approach)
info = physics.get_physics_info()
logger.info(f"Physics info: {info}")
# Test agent registration (Alice's approach)
agent_id = physics.register_agent([0, 5, 0]) # Drop agent from height
logger.info(f"Registered agent with ID: {agent_id}")
# Run a few physics steps (Alice's approach)
for i in range(5):
physics.step(1/60) # 60 FPS timestep
if agent_id:
pos = physics.get_agent_position(agent_id)
if pos:
logger.info(f"Agent position after step {i+1}: {pos}")
# Test cleanup (Alice's approach)
physics.cleanup()
logger.info("✅ Physics Engine tests passed")
return True
except Exception as e:
logger.error(f"❌ Physics Engine test failed: {e}")
return False
def test_agent_base():
"""Test Alice's enhanced agent base"""
logger.info("=== Testing Enhanced Agent Base (Alice's approach) ===")
try:
from src.core.agent_base import AgentBase
from src.utils.config_utils import ConfigManager
# Create config for the agent
config = ConfigManager()
# Create a concrete agent class (Alice's approach)
class TestAgent(AgentBase):
def __init__(self, name="TestAgent"):
super().__init__(name, config.get_all())
def update(self, delta_time: float):
# Override with test implementation
pass
# Test agent creation (Alice's approach)
agent = TestAgent("TestAgent")
# Test agent info (Alice's approach)
stats = agent.get_stats()
logger.info(f"Agent stats: {stats}")
# Test event system (Alice's approach)
event_received = False
def test_event_handler(data):
nonlocal event_received
event_received = True
logger.info(f"Received test event: {data}")
agent.register_event_handler("test_event", test_event_handler)
agent.emit_event("test_event", {"message": "Alice's event system working!"})
if event_received:
logger.info("Event system working correctly")
else:
logger.warning("Event system may not be working")
logger.info("✅ Enhanced Agent Base tests passed")
return True
except Exception as e:
logger.error(f"❌ Enhanced Agent Base test failed: {e}")
return False
def test_voice_manager():
"""Test Alice's voice manager framework"""
logger.info("=== Testing Voice Manager Framework (Alice's approach) ===")
try:
from src.voice.voice_manager import VoiceManager
# Test voice manager creation (Alice's approach)
voice_manager = VoiceManager()
# Test voice info (Alice's approach)
info = voice_manager.get_voice_info()
logger.info(f"Voice info: {info}")
# Test basic functionality (Alice's approach)
result = voice_manager.synthesize_speech("Testing Alice's voice system!", voice_id="default")
logger.info(f"Speech synthesis result: {result}")
logger.info("✅ Voice Manager tests passed")
return True
except Exception as e:
logger.error(f"❌ Voice Manager test failed: {e}")
return False
def main():
"""Run all tests for Alice's enhanced features"""
logger.info("🚀 Starting Enhanced Features Test Suite")
logger.info("Testing features copied from Alice's sophisticated Python work")
test_results = []
# Run all tests (Alice's approach)
tests = [
("Math Utils", test_math_utils),
("Config Manager", test_config_manager),
("Action System", test_action_system),
("Physics Engine", test_physics_engine),
("Agent Base", test_agent_base),
("Voice Manager", test_voice_manager)
]
for test_name, test_func in tests:
logger.info(f"\n--- Running {test_name} Test ---")
try:
result = test_func()
test_results.append((test_name, result))
except Exception as e:
logger.error(f"Test {test_name} crashed: {e}")
test_results.append((test_name, False))
# Summary (Alice's approach)
logger.info("\n" + "="*60)
logger.info("🎯 TEST SUMMARY")
logger.info("="*60)
passed = 0
total = len(test_results)
for test_name, result in test_results:
status = "✅ PASSED" if result else "❌ FAILED"
logger.info(f"{test_name:20} {status}")
if result:
passed += 1
logger.info("="*60)
logger.info(f"Total: {passed}/{total} tests passed")
if passed == total:
logger.info("🎉 All Alice features working perfectly!")
logger.info("Successfully copied Alice's sophisticated Python architecture")
else:
logger.warning(f"⚠️ {total-passed} tests failed - some features need attention")
return passed == total
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)