from tools.mediatools import ( compute_dominant_color, dominant_color_from_rgb, extract_frame, ) def test_dominant_color_from_rgb_pure_red(): assert dominant_color_from_rgb(b"\xff\x00\x00") == "#ff0000" def test_dominant_color_from_rgb_arbitrary(): assert dominant_color_from_rgb(b"\x12\xab\x0f") == "#12ab0f" def test_compute_dominant_color_uses_runner(): captured = {} def fake_runner(args): captured["args"] = args return b"\x00\x80\xff" color = compute_dominant_color("clip.mp4", midpoint_s=5.0, runner=fake_runner) assert color == "#0080ff" assert "ffmpeg" in captured["args"] assert "5.0" in captured["args"] def test_extract_frame_invokes_runner_and_returns_dest(tmp_path): dest = tmp_path / "frame.png" calls = [] def fake_runner(args): calls.append(args) out = extract_frame("clip.mp4", dest, midpoint_s=2.0, runner=fake_runner) assert out == dest assert calls and "ffmpeg" in calls[0] and str(dest) in calls[0]