autoseo-engine / test_system.py
Ahmed766's picture
Upload test_system.py with huggingface_hub
a8e9f9b verified
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)