test: lock OCR phase5 evidence object contract

This commit is contained in:
Research Assistant 2026-06-05 12:14:18 +08:00
parent 5d243c8e72
commit aa342c3e6a
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,21 @@
from __future__ import annotations
def test_evidence_object_preserves_role_page_confidence_and_asset() -> None:
from paperforge.worker.ocr_evidence import build_evidence_hit
hit = build_evidence_hit(
paper_id="KEY001",
role="figure_caption",
page=7,
block_id="p7_b18",
text="Figure 3. Results.",
asset_path="render/figures/figure_003.md",
confidence=0.84,
verification="has_page_crop",
)
assert hit["source_type"] == "figure_caption"
assert hit["page"] == 7
assert hit["asset"] == "render/figures/figure_003.md"
assert hit["confidence"] == 0.84

View file

@ -0,0 +1,23 @@
from __future__ import annotations
def test_paper_context_includes_evidence_summary() -> None:
from paperforge.worker.ocr_evidence import build_paper_evidence_summary
summary = build_paper_evidence_summary(
paper_id="KEY001",
role_indexes={
"body": [{"role": "body_paragraph", "text": "Text..."}],
"captions": [{"role": "figure_caption", "text": "Figure 1."}],
"references": [{"role": "reference_item", "text": "Smith 2024."}],
"metadata": [{"role": "metadata_title", "text": "Paper Title"}],
"tables": [],
},
)
assert "total_evidence_blocks" in summary
assert summary["total_evidence_blocks"] == 4
assert "by_role" in summary
assert summary["by_role"]["body"] == 1
assert summary["by_role"]["captions"] == 1
assert "has_figures" in summary or "has_tables" in summary