Spaces:
Running
on
Zero
Running
on
Zero
File size: 861 Bytes
eab0adb |
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 |
import pytest
import os
import cv2
from PIL import Image
from pathlib import Path
from src.app import get_frames
# Get the project root directory
ROOT_DIR = Path(__file__).parent.parent
def test_correct_frame_return():
"""Test that get_frames returns a list of (Image, float) tuples."""
# Path to a test video file
video_path = os.path.join(ROOT_DIR, "assets", "test_video.mp4")
# Ensure the test video exists
assert os.path.exists(video_path), f"Test video not found at {video_path}"
# Test with a small number of frames
max_images = 3
frames = get_frames(video_path, max_images)
# Check return type
assert isinstance(frames, list)
assert all(isinstance(item, tuple) and len(item) == 2 for item in frames)
assert all(isinstance(img, Image.Image) and isinstance(ts, float) for img, ts in frames) |