test(fixtures): replace sector-specific example material with generic, fictitious examples — green
Every fixture, test document, tool example and document now uses an invented kitchen-and-baking handbook series, written in this repository. The package's behaviour is unchanged; src/ changes are comments and help text only. - Generated fixtures are regenerated from their generators. Their structural counts are identical before and after: elements, images, rows, cells, headings, bookmarks and the witness inventory's per-document totals. The image-inbox and accounting documents are renamed kapittel-84-*. - tools/okf_accounting_gate.py: the two options that named one real corpus each are replaced by a generic, repeatable --corpus PATH with no default. Row 5 compares the PDF pair alone. Gate verdict unchanged: RED rows 2, 3, 6. - tools/okf_witness.py: the STS JSON reader for one publisher's delivery is removed, along with its three twins and five tests. The mutation harness loses W09. - docs/: 13 dated reports that documented runs on a retired reference corpus are removed, and 40 are neutralized. Dead links are removed, and no new dangling path is introduced. - The synthetic MCP-gate corpus and the residual probe words are neutral. Valgt: keep the `okf quality --fasit` bar value (the measured fraction, one corpus) and rewrite only its provenance, because the verdict stays unchanged and the number names nothing. Term check with the local list: 0 of 411 tracked files, 0 file names, 0 of 27 binary fixtures. Suite after git add: 2457 passed, 1 skipped. The base tree had 2460 passed and 2 skipped; five tests went with the JSON reader and four were added by the term check. ruff, ruff format and mypy --strict src/ are clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e7345a401
commit
9d1f4b14ed
174 changed files with 1889 additions and 6512 deletions
|
|
@ -33,7 +33,7 @@ from llm_ingestion_okf.structure import derive_document_structure
|
|||
|
||||
INGESTED_AT = "2026-07-25T12:00:00Z"
|
||||
|
||||
DOCUMENT = "# Brannkonsept\n\nSeksjonering etter N500.\n"
|
||||
DOCUMENT = "# Brannkonsept\n\nSeksjonering etter Q500.\n"
|
||||
|
||||
|
||||
def gate(text: str) -> GateDecision:
|
||||
|
|
@ -72,7 +72,7 @@ def tree(bundle: Path) -> dict[str, bytes]:
|
|||
|
||||
|
||||
def test_default_without_values_writes_what_it_wrote_before(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "a", "n500-vegbygging.md")
|
||||
drop(tmp_path / "a", "q500-surdeigsbaking.md")
|
||||
process_inbox(
|
||||
tmp_path / "a",
|
||||
tmp_path / "old",
|
||||
|
|
@ -81,7 +81,7 @@ def test_default_without_values_writes_what_it_wrote_before(tmp_path: Path) -> N
|
|||
gate=gate,
|
||||
profile=DEFAULT,
|
||||
)
|
||||
drop(tmp_path / "b", "n500-vegbygging.md")
|
||||
drop(tmp_path / "b", "q500-surdeigsbaking.md")
|
||||
process_inbox(
|
||||
tmp_path / "b",
|
||||
tmp_path / "new",
|
||||
|
|
@ -96,7 +96,7 @@ def test_default_without_values_writes_what_it_wrote_before(tmp_path: Path) -> N
|
|||
|
||||
|
||||
def test_structured_v1_without_values_still_writes_no_frontmatter(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "round", "n500-vegbygging.md")
|
||||
drop(tmp_path / "round", "q500-surdeigsbaking.md")
|
||||
run(tmp_path, profile=STRUCTURED_V1)
|
||||
assert not (tmp_path / "bundle" / "index.md").read_text(encoding="utf-8").startswith("---")
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ def test_structured_v1_without_values_still_writes_no_frontmatter(tmp_path: Path
|
|||
|
||||
|
||||
def test_the_root_index_opens_with_the_declared_bundle_id(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "round", "n500-vegbygging.md")
|
||||
drop(tmp_path / "round", "q500-surdeigsbaking.md")
|
||||
run(tmp_path, values={"bundle_id": "b-1"})
|
||||
body = (tmp_path / "bundle" / "index.md").read_text(encoding="utf-8")
|
||||
assert body.startswith("---\nbundle_id: b-1\n---\n\n")
|
||||
|
|
@ -115,15 +115,15 @@ def test_the_value_is_written_verbatim_and_unquoted(tmp_path: Path) -> None:
|
|||
# Read as RAW BYTES: a parsed assertion returns the same string whether or
|
||||
# not the emitter added quotes, so it would mask exactly the defect a
|
||||
# consumer's shape gate trips on.
|
||||
drop(tmp_path / "round", "n500-vegbygging.md")
|
||||
run(tmp_path, values={"bundle_id": "svv-n500-2026"})
|
||||
assert b"bundle_id: svv-n500-2026\n" in (tmp_path / "bundle" / "index.md").read_bytes()
|
||||
drop(tmp_path / "round", "q500-surdeigsbaking.md")
|
||||
run(tmp_path, values={"bundle_id": "eks-q500-2026"})
|
||||
assert b"bundle_id: eks-q500-2026\n" in (tmp_path / "bundle" / "index.md").read_bytes()
|
||||
|
||||
|
||||
def test_a_second_round_does_not_double_the_block(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "one", "n500-vegbygging.md")
|
||||
drop(tmp_path / "one", "q500-surdeigsbaking.md")
|
||||
run(tmp_path, values={"bundle_id": "b-1"}, round_name="one")
|
||||
drop(tmp_path / "two", "v720-tunnel.md")
|
||||
drop(tmp_path / "two", "w720-kjeller.md")
|
||||
run(tmp_path, values={"bundle_id": "b-1"}, round_name="two")
|
||||
body = (tmp_path / "bundle" / "index.md").read_text(encoding="utf-8")
|
||||
assert body.startswith("---\nbundle_id: b-1\n---\n\n")
|
||||
|
|
@ -131,18 +131,18 @@ def test_a_second_round_does_not_double_the_block(tmp_path: Path) -> None:
|
|||
|
||||
|
||||
def test_the_index_still_carries_its_entries_below_the_block(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "round", "n500-vegbygging.md")
|
||||
drop(tmp_path / "round", "q500-surdeigsbaking.md")
|
||||
run(tmp_path, values={"bundle_id": "b-1"})
|
||||
body = (tmp_path / "bundle" / "index.md").read_text(encoding="utf-8")
|
||||
assert "](inbox-n500-vegbygging.md)" in body
|
||||
assert body.index("bundle_id") < body.index("](inbox-n500-vegbygging.md)")
|
||||
assert "](inbox-q500-surdeigsbaking.md)" in body
|
||||
assert body.index("bundle_id") < body.index("](inbox-q500-surdeigsbaking.md)")
|
||||
|
||||
|
||||
# --- fail-fast, before any disk mutation ----------------------------------
|
||||
|
||||
|
||||
def test_a_key_the_policy_does_not_name_is_refused_before_any_write(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "round", "n500-vegbygging.md")
|
||||
drop(tmp_path / "round", "q500-surdeigsbaking.md")
|
||||
before = tree(tmp_path / "bundle")
|
||||
with pytest.raises(MaterializationError) as excinfo:
|
||||
run(tmp_path, values={"okf_version": "0.2"})
|
||||
|
|
@ -154,12 +154,12 @@ def test_a_key_the_policy_does_not_name_is_refused_before_any_write(tmp_path: Pa
|
|||
|
||||
|
||||
def test_a_refusal_leaves_an_existing_bundle_untouched(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "one", "n500-vegbygging.md")
|
||||
drop(tmp_path / "one", "q500-surdeigsbaking.md")
|
||||
run(tmp_path, values={"bundle_id": "b-1"}, round_name="one")
|
||||
before = tree(tmp_path / "bundle")
|
||||
assert before != {}
|
||||
|
||||
drop(tmp_path / "two", "v720-tunnel.md")
|
||||
drop(tmp_path / "two", "w720-kjeller.md")
|
||||
with pytest.raises(MaterializationError) as excinfo:
|
||||
run(tmp_path, values={"okf_version": "0.2"}, round_name="two")
|
||||
assert excinfo.value.code == "index_root_frontmatter_unexpected"
|
||||
|
|
@ -167,7 +167,7 @@ def test_a_refusal_leaves_an_existing_bundle_untouched(tmp_path: Path) -> None:
|
|||
|
||||
|
||||
def test_values_are_refused_against_a_profile_naming_no_root_keys(tmp_path: Path) -> None:
|
||||
drop(tmp_path / "round", "n500-vegbygging.md")
|
||||
drop(tmp_path / "round", "q500-surdeigsbaking.md")
|
||||
with pytest.raises(MaterializationError) as excinfo:
|
||||
run(tmp_path, profile=DEFAULT, values={"bundle_id": "b-1"})
|
||||
assert excinfo.value.code == "index_root_frontmatter_unexpected"
|
||||
|
|
@ -209,7 +209,7 @@ def render(**overrides: object) -> str:
|
|||
arguments: dict[str, object] = {
|
||||
"okf_type": "reference",
|
||||
"title": "Brannkonsept",
|
||||
"source_file": "n500.md",
|
||||
"source_file": "q500.md",
|
||||
"source_bytes": b"raw",
|
||||
"ingested_at": INGESTED_AT,
|
||||
"profile": SEGMENTED_V1,
|
||||
|
|
@ -295,7 +295,7 @@ def test_default_without_the_new_parameters_is_byte_identical() -> None:
|
|||
DOCUMENT,
|
||||
okf_type="reference",
|
||||
title="Brannkonsept",
|
||||
source_file="n500.md",
|
||||
source_file="q500.md",
|
||||
source_bytes=b"raw",
|
||||
ingested_at=INGESTED_AT,
|
||||
profile=DEFAULT,
|
||||
|
|
@ -380,14 +380,14 @@ def test_a_genuinely_derived_field_is_still_marked_on_a_segment() -> None:
|
|||
`number` here IS inferred from the body, and nothing about segmentation
|
||||
makes it declared, so it must survive in `derived`.
|
||||
"""
|
||||
body = "# N500 Vegtunneler\n\nSe N100.\n"
|
||||
derived = structure_of(body, "n500.md").derived
|
||||
body = "# Q500 Vinkjellere\n\nSe Q100.\n"
|
||||
derived = structure_of(body, "q500.md").derived
|
||||
assert {"title", "number"} <= derived # the premise, measured
|
||||
keys = frontmatter_of(
|
||||
render(
|
||||
text=body,
|
||||
title="Vegtunneler",
|
||||
structure=structure_of(body, "n500.md"),
|
||||
title="Vinkjellere",
|
||||
structure=structure_of(body, "q500.md"),
|
||||
segment=segment_entry(),
|
||||
bundle_id="b-1",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue