"""Unit tests for the fiction-wing probe harness's pure helpers. Only the network-free helpers are covered here; the live retrieval paths (search_library / reference_knowledge) are exercised by running the harness against a live Worldtree index, not by pytest. """ import sys from pathlib import Path _DIAG = Path(__file__).resolve().parent.parent / "docs" / "diagnostics" sys.path.insert(0, str(_DIAG)) from fiction_wing_probe import _on_target # noqa: E402 CURLY = "’" # noqa: RUF001 - the b170 extraction's default apostrophe def test_on_target_matches_curly_apostrophe_excerpt(): # Excerpt stores the curly apostrophe; keyword is ASCII. Must still match. excerpt = f"Mr. Darcy{CURLY}s letter to Elizabeth explains his conduct." assert _on_target(excerpt, ["darcy's letter"]) def test_on_target_matches_ascii_excerpt_against_curly_keyword(): # Symmetric: ASCII excerpt, curly-quoted keyword. Fold both sides. excerpt = "Mrs. Gardiner's letter arrived the next morning." assert _on_target(excerpt, [f"gardiner{CURLY}s letter"]) def test_on_target_still_rejects_absent_subject(): # Negative control: folding must not make unrelated excerpts match. excerpt = "A passage about dungeons, crawlers, and monsters." assert not _on_target(excerpt, ["darcy's letter"])