Spaces:
No application file
No application file
| #!/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()) | |