cadence/tests/conftest.py
pedro-bento ed8c0145ff
All checks were successful
CI / lint-and-test (push) Successful in 11s
Version 0.1.0 (#1)
Reviewed-on: #1
Co-authored-by: pedro-bento <mail@pbento.pt>
Co-committed-by: pedro-bento <mail@pbento.pt>
2026-09-30 18:33:59 +01:00

43 lines
1.1 KiB
Python

import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import pytest # noqa: E402
import cadence # noqa: E402
@pytest.fixture
def make_track(tmp_path):
"""Small factory for building VideoTrackData objects in tests."""
def _make(
*,
name: str = "video.mp4",
duration: float = 2.0,
fps_num: int = 30,
fps_den: int = 1,
width: int = 1920,
height: int = 1080,
audio_track_idx: int = 0,
audio_stream_count: int = 1,
words: list | None = None,
timeline: list | None = None,
) -> cadence.VideoTrackData:
if timeline is None:
timeline = [cadence.Segment(0.0, duration, "keep")]
return cadence.VideoTrackData(
video=tmp_path / name,
duration=duration,
fps_num=fps_num,
fps_den=fps_den,
width=width,
height=height,
audio_track_idx=audio_track_idx,
audio_stream_count=audio_stream_count,
words=list(words) if words else [],
timeline=list(timeline),
)
return _make