Ahmed766 commited on
Commit
a8e9f9b
Β·
verified Β·
1 Parent(s): 6298f9a

Upload test_system.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. test_system.py +139 -0
test_system.py ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import sys
3
+ import os
4
+ from pathlib import Path
5
+
6
+ # Add the project root to the Python path
7
+ project_root = Path(__file__).parent
8
+ sys.path.insert(0, str(project_root))
9
+
10
+ def test_imports():
11
+ """Test that all modules can be imported without errors"""
12
+ print("Testing module imports...")
13
+
14
+ try:
15
+ from core.models import AgentConfig, Task, AgentMessage, SEOData
16
+ print("βœ“ Core models imported successfully")
17
+ except ImportError as e:
18
+ print(f"βœ— Failed to import core models: {e}")
19
+ return False
20
+
21
+ try:
22
+ from core.agent import BaseAgent
23
+ print("βœ“ Base agent imported successfully")
24
+ except ImportError as e:
25
+ print(f"βœ— Failed to import base agent: {e}")
26
+ return False
27
+
28
+ try:
29
+ from core.monetization import MonetizationEngine
30
+ print("βœ“ Monetization engine imported successfully")
31
+ except ImportError as e:
32
+ print(f"βœ— Failed to import monetization engine: {e}")
33
+ return False
34
+
35
+ # Test agent imports
36
+ agent_modules = [
37
+ "agents.ceo_agent",
38
+ "agents.seo_director_agent",
39
+ "agents.tech_seo_agent",
40
+ "agents.content_seo_agent",
41
+ "agents.programmatic_seo_agent",
42
+ "agents.link_authority_agent",
43
+ "agents.conversion_cro_agent",
44
+ "agents.client_management_agent",
45
+ "agents.automation_ops_agent",
46
+ "agents.self_improvement_agent"
47
+ ]
48
+
49
+ for module in agent_modules:
50
+ try:
51
+ __import__(module)
52
+ print(f"βœ“ {module} imported successfully")
53
+ except ImportError as e:
54
+ print(f"βœ— Failed to import {module}: {e}")
55
+ return False
56
+
57
+ print("βœ“ All modules imported successfully!")
58
+ return True
59
+
60
+ def test_monetization():
61
+ """Test monetization engine functionality"""
62
+ print("\nTesting monetization engine...")
63
+
64
+ try:
65
+ from core.monetization import MonetizationEngine
66
+
67
+ # Create monetization engine
68
+ engine = MonetizationEngine()
69
+
70
+ # Add a test customer
71
+ asyncio.run(engine.add_customer({"name": "Test Customer", "tier": "professional"}))
72
+
73
+ # Calculate MRR
74
+ mrr = asyncio.run(engine.calculate_mrr())
75
+ print(f"βœ“ MRR calculated: ${mrr}")
76
+
77
+ # Generate performance bonus
78
+ perf_metrics = {"revenue_increase": 10000}
79
+ bonus = asyncio.run(engine.generate_performance_bonus("cust_1", perf_metrics))
80
+ print(f"βœ“ Performance bonus calculated: ${bonus}")
81
+
82
+ # Get dashboard
83
+ dashboard = asyncio.run(engine.get_monetization_dashboard())
84
+ print(f"βœ“ Monetization dashboard retrieved with {dashboard['customer_metrics']['total_customers']} customers")
85
+
86
+ print("βœ“ Monetization engine working correctly!")
87
+ return True
88
+
89
+ except Exception as e:
90
+ print(f"βœ— Monetization engine test failed: {e}")
91
+ return False
92
+
93
+ def test_agent_creation():
94
+ """Test agent creation and basic functionality"""
95
+ print("\nTesting agent creation...")
96
+
97
+ try:
98
+ from core.models import AgentConfig
99
+ from agents.ceo_agent import CEOStrategyAgent
100
+
101
+ # Create a CEO agent
102
+ config = AgentConfig(name="test_ceo", enabled=True, max_iterations=2)
103
+ agent = CEOStrategyAgent(config)
104
+
105
+ print(f"βœ“ CEO agent created with name: {agent.name}")
106
+
107
+ # Test basic properties
108
+ assert agent.enabled == True
109
+ assert agent.max_iterations == 2
110
+ print("βœ“ Agent properties set correctly")
111
+
112
+ print("βœ“ Agent creation working correctly!")
113
+ return True
114
+
115
+ except Exception as e:
116
+ print(f"βœ— Agent creation test failed: {e}")
117
+ return False
118
+
119
+ def main():
120
+ """Run all tests"""
121
+ print("AutoSEO Engine - Validation Tests\n")
122
+ print("="*40)
123
+
124
+ success = True
125
+ success &= test_imports()
126
+ success &= test_monetization()
127
+ success &= test_agent_creation()
128
+
129
+ print("\n" + "="*40)
130
+ if success:
131
+ print("πŸŽ‰ All tests passed! AutoSEO Engine is ready.")
132
+ else:
133
+ print("❌ Some tests failed. Please check the implementation.")
134
+
135
+ return success
136
+
137
+ if __name__ == "__main__":
138
+ success = main()
139
+ sys.exit(0 if success else 1)