BladeSzaSza's picture
fix: define REPO_NAME in hf_upload.sh (ensure_blade_space referenced it)
4948993 verified
Raw
History Blame Contribute Delete
2.25 kB
"""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)