File size: 4,341 Bytes
a8e9f9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import asyncio
import sys
import os
from pathlib import Path

# Add the project root to the Python path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))

def test_imports():
    """Test that all modules can be imported without errors"""
    print("Testing module imports...")
    
    try:
        from core.models import AgentConfig, Task, AgentMessage, SEOData
        print("βœ“ Core models imported successfully")
    except ImportError as e:
        print(f"βœ— Failed to import core models: {e}")
        return False
    
    try:
        from core.agent import BaseAgent
        print("βœ“ Base agent imported successfully")
    except ImportError as e:
        print(f"βœ— Failed to import base agent: {e}")
        return False
    
    try:
        from core.monetization import MonetizationEngine
        print("βœ“ Monetization engine imported successfully")
    except ImportError as e:
        print(f"βœ— Failed to import monetization engine: {e}")
        return False
    
    # Test agent imports
    agent_modules = [
        "agents.ceo_agent",
        "agents.seo_director_agent", 
        "agents.tech_seo_agent",
        "agents.content_seo_agent",
        "agents.programmatic_seo_agent",
        "agents.link_authority_agent",
        "agents.conversion_cro_agent",
        "agents.client_management_agent",
        "agents.automation_ops_agent",
        "agents.self_improvement_agent"
    ]
    
    for module in agent_modules:
        try:
            __import__(module)
            print(f"βœ“ {module} imported successfully")
        except ImportError as e:
            print(f"βœ— Failed to import {module}: {e}")
            return False
    
    print("βœ“ All modules imported successfully!")
    return True

def test_monetization():
    """Test monetization engine functionality"""
    print("\nTesting monetization engine...")
    
    try:
        from core.monetization import MonetizationEngine
        
        # Create monetization engine
        engine = MonetizationEngine()
        
        # Add a test customer
        asyncio.run(engine.add_customer({"name": "Test Customer", "tier": "professional"}))
        
        # Calculate MRR
        mrr = asyncio.run(engine.calculate_mrr())
        print(f"βœ“ MRR calculated: ${mrr}")
        
        # Generate performance bonus
        perf_metrics = {"revenue_increase": 10000}
        bonus = asyncio.run(engine.generate_performance_bonus("cust_1", perf_metrics))
        print(f"βœ“ Performance bonus calculated: ${bonus}")
        
        # Get dashboard
        dashboard = asyncio.run(engine.get_monetization_dashboard())
        print(f"βœ“ Monetization dashboard retrieved with {dashboard['customer_metrics']['total_customers']} customers")
        
        print("βœ“ Monetization engine working correctly!")
        return True
        
    except Exception as e:
        print(f"βœ— Monetization engine test failed: {e}")
        return False

def test_agent_creation():
    """Test agent creation and basic functionality"""
    print("\nTesting agent creation...")
    
    try:
        from core.models import AgentConfig
        from agents.ceo_agent import CEOStrategyAgent
        
        # Create a CEO agent
        config = AgentConfig(name="test_ceo", enabled=True, max_iterations=2)
        agent = CEOStrategyAgent(config)
        
        print(f"βœ“ CEO agent created with name: {agent.name}")
        
        # Test basic properties
        assert agent.enabled == True
        assert agent.max_iterations == 2
        print("βœ“ Agent properties set correctly")
        
        print("βœ“ Agent creation working correctly!")
        return True
        
    except Exception as e:
        print(f"βœ— Agent creation test failed: {e}")
        return False

def main():
    """Run all tests"""
    print("AutoSEO Engine - Validation Tests\n")
    print("="*40)
    
    success = True
    success &= test_imports()
    success &= test_monetization()
    success &= test_agent_creation()
    
    print("\n" + "="*40)
    if success:
        print("πŸŽ‰ All tests passed! AutoSEO Engine is ready.")
    else:
        print("❌ Some tests failed. Please check the implementation.")
    
    return success

if __name__ == "__main__":
    success = main()
    sys.exit(0 if success else 1)