Spaces:
Running
Running
File size: 2,124 Bytes
2c584b2 |
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 77 78 |
#!/usr/bin/env python3
"""
Simple test script for VR180 Converter API
"""
import requests
import json
import os
import time
def test_health():
"""Test health endpoint"""
try:
response = requests.get('http://localhost:5000/api/health')
print(f"Health check: {response.status_code}")
print(f"Response: {response.json()}")
return response.status_code == 200
except Exception as e:
print(f"Health check failed: {e}")
return False
def test_upload():
"""Test file upload"""
try:
# Create a simple test video file (1 second of black frames)
import cv2
import numpy as np
# Create a simple test video
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('test_video.mp4', fourcc, 30.0, (640, 480))
for i in range(30): # 1 second at 30fps
frame = np.zeros((480, 640, 3), dtype=np.uint8)
out.write(frame)
out.release()
# Upload the test video
with open('test_video.mp4', 'rb') as f:
files = {'video': f}
response = requests.post('http://localhost:5000/api/upload', files=files)
print(f"Upload test: {response.status_code}")
print(f"Response: {response.json()}")
# Clean up
os.remove('test_video.mp4')
return response.status_code == 200
except Exception as e:
print(f"Upload test failed: {e}")
return False
def main():
print("Testing VR180 Converter API...")
print("=" * 40)
# Test health endpoint
if test_health():
print("✓ Health check passed")
else:
print("✗ Health check failed")
return
# Test upload endpoint
if test_upload():
print("✓ Upload test passed")
else:
print("✗ Upload test failed")
return
print("=" * 40)
print("All tests passed! API is working correctly.")
if __name__ == "__main__":
main()
|