feat(video_analysis): synthesize_report.py orchestrator with TDD (5 tests)

This commit is contained in:
ed
2026-06-21 15:39:22 -04:00
parent ed0d198afe
commit 548c4fef63
2 changed files with 166 additions and 0 deletions
@@ -0,0 +1,53 @@
from __future__ import annotations
from pathlib import Path
from unittest.mock import patch
from scripts.video_analysis.extract_transcript import ok as extract_ok
from scripts.video_analysis.download_video import ok as download_ok
from scripts.video_analysis.extract_keyframes import ok as keyframes_ok
from scripts.video_analysis.ocr_frames import ok as ocr_ok
from scripts.video_analysis.synthesize_report import (
PIPELINE_STAGES,
ReportContext,
build_report_stub,
build_summary_stub,
synthesize_report,
)
def test_pipeline_stages_in_order() -> None:
assert PIPELINE_STAGES == ["transcript", "download", "keyframes", "ocr", "report"]
def test_report_context_dataclass() -> None:
ctx = ReportContext(url="https://youtu.be/VID", slug="vid", output_dir=Path("/tmp/vid"))
assert ctx.url == "https://youtu.be/VID"
assert ctx.slug == "vid"
def test_build_report_stub_has_sections() -> None:
stub = build_report_stub("vid", "https://youtu.be/VID", "VID123ABCDE")
assert "VID123ABCDE" in stub
assert "## 1. TL;DR" in stub
assert "## 8. References" in stub
def test_build_summary_stub_short() -> None:
stub = build_summary_stub("vid", "Title", "Author")
assert "vid" in stub
assert "Title" in stub
assert len(stub) < 500
def test_synthesize_report_orchestrates(tmp_path: Path) -> None:
with patch("scripts.video_analysis.synthesize_report.extract_transcript") as t, \
patch("scripts.video_analysis.synthesize_report.download_video") as d, \
patch("scripts.video_analysis.synthesize_report.extract_keyframes") as k, \
patch("scripts.video_analysis.synthesize_report.ocr_frames") as o:
t.return_value = extract_ok({})
d.return_value = download_ok({})
k.return_value = keyframes_ok({})
o.return_value = ocr_ok({})
result = synthesize_report("https://youtu.be/ABCDEFGHIJK", "vid", tmp_path, skip_video_download=True)
assert result.is_ok()