File size: 2,249 Bytes
a6db0c1 | 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 41 42 43 44 45 46 47 48 49 50 51 52 | """Tests for PdfReportAgent — no GPU, no model downloads."""
import os
from formscout.types import (
ReportResult, SessionEntry, MovementResult, BiomechFeatures, ScoreResult, JudgeResult,
)
def _entry(test_name="deep_squat", score=2, needs_human=False):
movement = MovementResult(test_name=test_name, side="na", confidence=1.0)
features = BiomechFeatures(
test_name=test_name, view="2d", side="na",
angles={"left_knee_flexion_deg": 95.0}, alignments={"knees_tracking_over_feet": False},
symmetry_delta=None, timing={"deepest_frame": 1}, confidence=0.9,
)
rubric = ScoreResult(score=2, rationale="rubric ok", confidence=0.8)
judge = JudgeResult(score=None if needs_human else score, rationale="judge rationale",
compensation_tags=["heels elevated"], corrective_hint="ankle mobility",
confidence=0.85, needs_human=needs_human)
return SessionEntry(
test_name=test_name, side="na", score=None if needs_human else score,
needs_human=needs_human, rationale="judge rationale",
compensation_tags=["heels elevated"], corrective_hint="ankle mobility",
measurements={"left_knee_flexion_deg": 95.0, "knees_tracking_over_feet": False},
confidence=0.85, view="2d", keyframe_path=None,
movement=movement, features=features, rubric_score=rubric, judge=judge,
)
def _report(composite=2):
return ReportResult(
per_test=[], composite=composite, asymmetries=[],
overlay_video_path=None, pdf_path=None,
low_confidence_flags=[], disagreement_flags=[],
)
def test_pdf_is_created(tmp_path):
from formscout.agents.pdf_report import PdfReportAgent
path = PdfReportAgent().run(_report(2), [_entry()], str(tmp_path))
assert path is not None
assert os.path.exists(path)
assert os.path.getsize(path) > 1000 # a real PDF, not an empty file
with open(path, "rb") as f:
assert f.read(5) == b"%PDF-"
def test_pdf_handles_incomplete_composite(tmp_path):
from formscout.agents.pdf_report import PdfReportAgent
path = PdfReportAgent().run(_report(None), [_entry(needs_human=True)], str(tmp_path))
assert path is not None and os.path.exists(path)
|