94 lines
2.9 KiB
Python
94 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify all imports work correctly
|
|
"""
|
|
|
|
import sys
|
|
import traceback
|
|
|
|
def test_import(module_name, import_statement):
|
|
"""Test a specific import."""
|
|
try:
|
|
exec(import_statement)
|
|
print(f"✅ {module_name}: OK")
|
|
return True
|
|
except ImportError as e:
|
|
print(f"❌ {module_name}: {e}")
|
|
return False
|
|
except Exception as e:
|
|
print(f"❌ {module_name}: Unexpected error - {e}")
|
|
return False
|
|
|
|
def main():
|
|
"""Test all required imports."""
|
|
print("🧪 Testing Discord Data Collector Imports")
|
|
print("=" * 50)
|
|
|
|
tests = [
|
|
("discord.py-self", "import discord"),
|
|
("toml", "import toml"),
|
|
("python-dotenv", "from dotenv import load_dotenv"),
|
|
("pathlib", "from pathlib import Path"),
|
|
("asyncio", "import asyncio"),
|
|
("logging", "import logging"),
|
|
("datetime", "from datetime import datetime"),
|
|
("json", "import json"),
|
|
("dataclasses", "from dataclasses import dataclass, asdict"),
|
|
("collections", "from collections import deque"),
|
|
("time", "import time"),
|
|
("typing", "from typing import Optional, Set, Dict, List, Any"),
|
|
]
|
|
|
|
failed = 0
|
|
for module_name, import_statement in tests:
|
|
if not test_import(module_name, import_statement):
|
|
failed += 1
|
|
|
|
print(f"\n📊 Results: {len(tests) - failed}/{len(tests)} imports successful")
|
|
|
|
if failed == 0:
|
|
print("✅ All imports successful! Testing local modules...")
|
|
|
|
# Test local modules
|
|
try:
|
|
# Add current directory to path
|
|
sys.path.insert(0, '.')
|
|
|
|
# Test config
|
|
from src.config import Config
|
|
print("✅ src.config: OK")
|
|
|
|
# Test database
|
|
from src.database import JSONDatabase, UserData
|
|
print("✅ src.database: OK")
|
|
|
|
# Test rate limiter
|
|
from src.rate_limiter import RateLimiter
|
|
print("✅ src.rate_limiter: OK")
|
|
|
|
# Test logger
|
|
from src.logger import setup_logger
|
|
print("✅ src.logger: OK")
|
|
|
|
# Test client
|
|
from src.client import DiscordDataClient
|
|
print("✅ src.client: OK")
|
|
|
|
print("\n🎉 All tests passed! The application should work correctly.")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Local module test failed: {e}")
|
|
print("\nDetailed error:")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
else:
|
|
print(f"\n❌ {failed} import(s) failed. Please install missing dependencies:")
|
|
print("pip install discord.py-self python-dotenv toml colorlog")
|
|
return False
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
success = main()
|
|
sys.exit(0 if success else 1) |