Files
vt1200/bad-apple/tests/test_build.py
T

22 lines
780 B
Python

import json
import numpy as np
import pipeline.build as build
from pipeline.movie import read_movie
def test_build_tiny_movie(tmp_path, monkeypatch):
frames = [np.zeros((64, 64), dtype=bool) for _ in range(3)]
frames[1][8:24, 8:24] = True
monkeypatch.setattr(build, "extract_binary", lambda *a, **k: iter(frames))
monkeypatch.setattr(build, "vectorize_frame", lambda m, p: m)
out = tmp_path / "data"
manifest = build.build_movie("unused.mp4", str(out),
{"duration": 3, "fps": 60})
header, recs = read_movie(str(out / "movie.bin"))
assert header.frame_count == 3
assert len(recs) == 3
assert (out / "manifest.json").exists()
assert json.loads((out / "manifest.json").read_text())["frame_count"] == 3