#!/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)