#!/usr/bin/env python3 """ Test script to verify the video generator works locally before deployment """ import os import sys from pathlib import Path def test_imports(): """Test if all required packages can be imported""" try: import gradio as gr print("✅ Gradio imported successfully") import google.generativeai as genai print("✅ Google Generative AI imported successfully") import manim print("✅ Manim imported successfully") import numpy print("✅ NumPy imported successfully") return True except ImportError as e: print(f"❌ Import error: {e}") return False def test_api_key(): """Test if API key is available""" api_key = os.getenv("GEMINI_API_KEY") if api_key: print("✅ GEMINI_API_KEY found") return True else: print("⚠️ GEMINI_API_KEY not found - set it in environment variables") return False def test_manim(): """Test if Manim can run a simple scene""" try: from manim import Scene, Text, FadeIn print("✅ Manim core classes imported successfully") return True except Exception as e: print(f"❌ Manim test failed: {e}") return False def main(): """Run all tests""" print("🧪 Running pre-deployment tests...\n") all_tests = [ ("Import Test", test_imports), ("API Key Test", test_api_key), ("Manim Test", test_manim), ] results = [] for test_name, test_func in all_tests: print(f"Running {test_name}...") result = test_func() results.append(result) print() if all(results): print("🎉 All tests passed! Ready for deployment to Hugging Face Spaces") return 0 else: print("❌ Some tests failed. Please fix the issues before deployment") return 1 if __name__ == "__main__": sys.exit(main())