File size: 1,210 Bytes
ead274c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Smoke test: read first frames of existing sample videos."""

import os
import pytest

from first_frame_reader import read_first_frames

THREESHOT = "/workspace/ComfyUI/input/test_3shots.mp4"
IMBA = "/workspace/ComfyUI/input/imba.mp4"


@pytest.mark.skipif(not os.path.exists(THREESHOT), reason="sample missing")
def test_read_single_clip_returns_1x_tensor():
    t = read_first_frames([THREESHOT])
    assert t.shape[0] == 1
    assert t.ndim == 4
    assert t.shape[3] == 3
    assert t.dtype.is_floating_point
    assert 0.0 <= t.min().item() and t.max().item() <= 1.0


@pytest.mark.skipif(not (os.path.exists(THREESHOT) and os.path.exists(IMBA)), reason="samples missing")
def test_read_multiple_clips_uses_first_as_reference_size():
    t = read_first_frames([THREESHOT, IMBA])
    assert t.shape[0] == 2
    # Second clip should be resized to match first
    assert t[0].shape == t[1].shape


def test_read_empty_list_returns_empty_tensor():
    t = read_first_frames([])
    assert t.shape[0] == 0


def test_read_missing_file_returns_black_fallback():
    t = read_first_frames(["/nonexistent/fake_clip.mp4"])
    assert t.shape[0] == 1
    # Black frame: all zeros
    assert t.max().item() == 0.0