File size: 2,168 Bytes
			
			| 3c6e0b2 | 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 | """
Test script for APScheduler service.
This script tests the basic functionality of the APScheduler service.
"""
import sys
import os
from pathlib import Path
# Add the backend directory to the Python path
backend_dir = Path(__file__).parent / "backend"
sys.path.insert(0, str(backend_dir))
def test_apscheduler_service():
    """Test the APScheduler service."""
    try:
        # Import the APScheduler service
        from scheduler.apscheduler_service import APSchedulerService
        
        # Create a mock app object
        class MockApp:
            def __init__(self):
                self.config = {
                    'SUPABASE_URL': 'test_url',
                    'SUPABASE_KEY': 'test_key',
                    'SCHEDULER_ENABLED': True
                }
        
        # Create a mock Supabase client
        class MockSupabaseClient:
            def table(self, table_name):
                return self
                
            def select(self, columns):
                return self
                
            def execute(self):
                # Return mock data
                return type('obj', (object,), {'data': []})()
        
        # Initialize the scheduler service
        app = MockApp()
        scheduler_service = APSchedulerService()
        
        # Mock the Supabase client initialization
        scheduler_service.supabase_client = MockSupabaseClient()
        
        # Test loading schedules
        scheduler_service.load_schedules()
        
        # Check if scheduler is initialized
        if scheduler_service.scheduler is not None:
            print("✓ APScheduler service initialized successfully")
            return True
        else:
            print("✗ APScheduler service failed to initialize")
            return False
            
    except Exception as e:
        print(f"✗ Error testing APScheduler service: {str(e)}")
        return False
if __name__ == "__main__":
    print("Testing APScheduler service...")
    success = test_apscheduler_service()
    if success:
        print("All tests passed!")
        sys.exit(0)
    else:
        print("Tests failed!")
        sys.exit(1) | 
