| """ |
| Test script for APScheduler service. |
| This script tests the basic functionality of the APScheduler service. |
| """ |
|
|
| import sys |
| import os |
| from pathlib import Path |
|
|
| |
| backend_dir = Path(__file__).parent / "backend" |
| sys.path.insert(0, str(backend_dir)) |
|
|
| def test_apscheduler_service(): |
| """Test the APScheduler service.""" |
| try: |
| |
| from scheduler.apscheduler_service import APSchedulerService |
| |
| |
| class MockApp: |
| def __init__(self): |
| self.config = { |
| 'SUPABASE_URL': 'test_url', |
| 'SUPABASE_KEY': 'test_key', |
| 'SCHEDULER_ENABLED': True |
| } |
| |
| |
| class MockSupabaseClient: |
| def table(self, table_name): |
| return self |
| |
| def select(self, columns): |
| return self |
| |
| def execute(self): |
| |
| return type('obj', (object,), {'data': []})() |
| |
| |
| app = MockApp() |
| scheduler_service = APSchedulerService() |
| |
| |
| scheduler_service.supabase_client = MockSupabaseClient() |
| |
| |
| scheduler_service.load_schedules() |
| |
| |
| 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) |