mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
test: lock OCR phase4 rebuild orchestration contract
This commit is contained in:
parent
633a59f998
commit
6c58212db3
2 changed files with 36 additions and 0 deletions
19
tests/test_ocr_rebuild.py
Normal file
19
tests/test_ocr_rebuild.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
"""Contract tests for OCR derived-rebuild orchestration (Phase 4)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def test_rebuild_selector_only_targets_derived_stale_papers() -> None:
|
||||
"""select_papers_for_derived_rebuild must only return papers
|
||||
where derived_stale=True, regardless of raw_upgradable status."""
|
||||
# This will fail with ModuleNotFoundError until paperforge/worker/ocr_rebuild.py exists
|
||||
from paperforge.worker.ocr_rebuild import select_papers_for_derived_rebuild
|
||||
|
||||
papers = [
|
||||
{"zotero_key": "A", "derived_stale": True, "raw_upgradable": False},
|
||||
{"zotero_key": "B", "derived_stale": False, "raw_upgradable": True},
|
||||
]
|
||||
|
||||
selected = select_papers_for_derived_rebuild(papers)
|
||||
|
||||
assert selected == ["A"]
|
||||
|
|
@ -203,3 +203,20 @@ def test_ocr_redo_rebuilds_phase3_artifacts(tmp_path) -> None:
|
|||
# Phase 3 artifacts should exist
|
||||
assert (ocr_dir / "render" / "fulltext.md").exists(), "render/fulltext.md missing after redo"
|
||||
assert (ocr_dir / "health" / "ocr_health.json").exists(), "health/ocr_health.json missing after redo"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Guard: redo must not become derived-rebuild path
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_redo_does_not_call_derived_rebuild() -> None:
|
||||
"""Verify ocr redo does not import or call derived rebuild.
|
||||
|
||||
This import will fail (ModuleNotFoundError) until Task 5 of Phase 4,
|
||||
which explicitly keeps redo and derived rebuild separate. If someone
|
||||
wires redo to use derived rebuild, this test should be updated or
|
||||
removed with explicit justification.
|
||||
"""
|
||||
from paperforge.worker.ocr_rebuild import select_papers_for_derived_rebuild
|
||||
|
||||
assert select_papers_for_derived_rebuild is not None
|
||||
|
|
|
|||
Loading…
Reference in a new issue