| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- """
- Unit test for launch_comfy_env
- Tests code structure without making real API calls
- """
- import sys
- import os
- # Add parent directory to path
- sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
- # Test imports
- try:
- from comfy_launcher import launch_comfy_server
- from main import app, LaunchRequest
- print("[OK] All imports successful")
- except Exception as e:
- print(f"[FAIL] Import failed: {e}")
- sys.exit(1)
- # Test data models
- try:
- req = LaunchRequest()
- assert req.version_id == "90f77137-ba75-400d-870f-204c614ae8a3"
- assert req.server_type == "medium"
- assert req.duration == 3600
- print("[OK] LaunchRequest model validated")
- except Exception as e:
- print(f"[FAIL] Model validation failed: {e}")
- sys.exit(1)
- # Test FastAPI app structure
- try:
- routes = [route.path for route in app.routes]
- assert "/launch" in routes
- print("[OK] FastAPI routes configured")
- except Exception as e:
- print(f"[FAIL] Route validation failed: {e}")
- sys.exit(1)
- print("\n[OK] All unit tests passed")
- print("Note: Real API calls require RUNCOMFY_USER_ID and API_TOKEN environment variables")
|