File size: 2,073 Bytes
1dfc9df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
72
73
74
75
76
#!/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())