-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_components.py
More file actions
120 lines (107 loc) · 4.18 KB
/
test_components.py
File metadata and controls
120 lines (107 loc) · 4.18 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
"""
Simple test script to verify that all components are working correctly
"""
import pandas as pd
import numpy as np
import sys
import os
# Add the project directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
def test_basic_functionality():
"""Test basic functionality of all components"""
print("Testing basic functionality...")
# Test 1: Basic imports
try:
from agents.collaboration_agent import CollaborationAgent, TeamWorkspace
from agents.ml_enhancement_agent import MLEnhancementAgent
from agents.user_profile_agent import UserProfileAgent, UserProfile
from agents.visualization_agent import VisualizationAgent
from agents.streaming_agent import StreamingAgent
from agents.data_agent import DataAgent
from agents.insight_agent import InsightAgent
from agents.risk_agent import RiskAgent
print("✓ All agents imported successfully")
except Exception as e:
print(f"✗ Error importing agents: {e}")
return False
# Test 2: Create sample data
try:
np.random.seed(42)
sample_data = pd.DataFrame({
'transaction_id': range(100),
'amount': np.random.exponential(100, 100),
'merchant': np.random.choice(['Amazon', 'Walmart', 'Target'], 100),
'category': np.random.choice(['Online', 'Retail', 'Food'], 100),
'is_fraud': np.random.choice([0, 1], 100, p=[0.9, 0.1])
})
print(f"✓ Sample data created ({len(sample_data)} rows)")
except Exception as e:
print(f"✗ Error creating sample data: {e}")
return False
# Test 3: Test Collaboration Agent
try:
collaboration_agent = CollaborationAgent()
workspace_id = collaboration_agent.create_workspace("Test Workspace", "user_123")
workspace = collaboration_agent.get_workspace(workspace_id)
print("✓ Collaboration agent working")
except Exception as e:
print(f"✗ Error with collaboration agent: {e}")
return False
# Test 4: Test ML Enhancement Agent
try:
ml_agent = MLEnhancementAgent()
result = ml_agent.natural_language_query(sample_data, "Show me high risk transactions")
print("✓ ML enhancement agent working")
except Exception as e:
print(f"✗ Error with ML enhancement agent: {e}")
return False
# Test 5: Test User Profile Agent
try:
profile_agent = UserProfileAgent()
profile = profile_agent.get_user_profile("user_123")
profile.set_preference("risk_threshold", 0.8)
print("✓ User profile agent working")
except Exception as e:
print(f"✗ Error with user profile agent: {e}")
return False
# Test 6: Test Visualization Agent
try:
viz_agent = VisualizationAgent()
visualizations = viz_agent.generate_advanced_visualizations(sample_data)
print(f"✓ Visualization agent working ({len(visualizations)} visualizations generated)")
except Exception as e:
print(f"✗ Error with visualization agent: {e}")
return False
# Test 7: Test Streaming Agent
try:
streaming_agent = StreamingAgent()
print("✓ Streaming agent working")
except Exception as e:
print(f"✗ Error with streaming agent: {e}")
return False
# Test 8: Test Data Agent
try:
data_agent = DataAgent()
data_agent.df = sample_data
processed_data = data_agent.clean_data()
print(f"✓ Data agent working ({len(processed_data)} rows processed)")
except Exception as e:
print(f"✗ Error with data agent: {e}")
return False
# Test 9: Test Risk Agent
try:
risk_agent = RiskAgent()
print("✓ Risk agent working")
except Exception as e:
print(f"✗ Error with risk agent: {e}")
return False
print("\n🎉 All components are working correctly!")
return True
if __name__ == "__main__":
success = test_basic_functionality()
if success:
print("\n✅ Integration test passed!")
sys.exit(0)
else:
print("\n❌ Integration test failed!")
sys.exit(1)