Prithwis commited on
Commit
525b493
·
verified ·
1 Parent(s): cb2084b

Upload scripts\test_app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts//test_app.py +77 -0
scripts//test_app.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Simple test script for VR180 Converter API
4
+ """
5
+
6
+ import requests
7
+ import json
8
+ import os
9
+ import time
10
+
11
+ def test_health():
12
+ """Test health endpoint"""
13
+ try:
14
+ response = requests.get('http://localhost:5000/api/health')
15
+ print(f"Health check: {response.status_code}")
16
+ print(f"Response: {response.json()}")
17
+ return response.status_code == 200
18
+ except Exception as e:
19
+ print(f"Health check failed: {e}")
20
+ return False
21
+
22
+ def test_upload():
23
+ """Test file upload"""
24
+ try:
25
+ # Create a simple test video file (1 second of black frames)
26
+ import cv2
27
+ import numpy as np
28
+
29
+ # Create a simple test video
30
+ fourcc = cv2.VideoWriter_fourcc(*'mp4v')
31
+ out = cv2.VideoWriter('test_video.mp4', fourcc, 30.0, (640, 480))
32
+
33
+ for i in range(30): # 1 second at 30fps
34
+ frame = np.zeros((480, 640, 3), dtype=np.uint8)
35
+ out.write(frame)
36
+
37
+ out.release()
38
+
39
+ # Upload the test video
40
+ with open('test_video.mp4', 'rb') as f:
41
+ files = {'video': f}
42
+ response = requests.post('http://localhost:5000/api/upload', files=files)
43
+
44
+ print(f"Upload test: {response.status_code}")
45
+ print(f"Response: {response.json()}")
46
+
47
+ # Clean up
48
+ os.remove('test_video.mp4')
49
+
50
+ return response.status_code == 200
51
+ except Exception as e:
52
+ print(f"Upload test failed: {e}")
53
+ return False
54
+
55
+ def main():
56
+ print("Testing VR180 Converter API...")
57
+ print("=" * 40)
58
+
59
+ # Test health endpoint
60
+ if test_health():
61
+ print("✓ Health check passed")
62
+ else:
63
+ print("✗ Health check failed")
64
+ return
65
+
66
+ # Test upload endpoint
67
+ if test_upload():
68
+ print("✓ Upload test passed")
69
+ else:
70
+ print("✗ Upload test failed")
71
+ return
72
+
73
+ print("=" * 40)
74
+ print("All tests passed! API is working correctly.")
75
+
76
+ if __name__ == "__main__":
77
+ main()