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
|
|
@ -48,13 +48,13 @@ IDENTITY = FIXTURES / "sts-identity.xml"
|
|||
OPAQUE = "0f1e2d3c-4b5a-6978-8796-a5b4c3d2e1f0.xml"
|
||||
|
||||
ADDRESS = "https://normer.example.test/api/sts/900?languageCode=nb"
|
||||
STATED_SOURCES = f"[{{ resource: {ADDRESS}, title: R900:2024 }}]"
|
||||
STATED_SOURCES = f"[{{ resource: {ADDRESS}, title: P900:2024 }}]"
|
||||
# K3-22: the address above carries `?`, which ends a plain scalar inside a
|
||||
# PyYAML flow mapping, and the guard refuses the quoted form -- so no build may
|
||||
# write it. The flag's GRAMMAR still takes it (it only splits); the build
|
||||
# refuses it. A build that writes an address uses this one.
|
||||
WRITABLE_ADDRESS = "https://normer.example.test/api/sts/900/nb"
|
||||
WRITABLE_SOURCES = f"[{{ resource: {WRITABLE_ADDRESS}, title: R900:2024 }}]"
|
||||
WRITABLE_SOURCES = f"[{{ resource: {WRITABLE_ADDRESS}, title: P900:2024 }}]"
|
||||
MARKDOWN = b"# Innledning\n\nTekst her.\n\n# Omfang\n\nMer tekst her.\n"
|
||||
|
||||
|
||||
|
|
@ -98,8 +98,8 @@ def _frontmatter_lines(path: Path) -> list[str]:
|
|||
|
||||
def test_the_flag_splits_on_the_first_equals_sign_and_only_there() -> None:
|
||||
assert cli.frontmatter_from_flags(
|
||||
[f"sources={STATED_SOURCES}", "utgave=R900:2024", "merknad=a=b"]
|
||||
) == {"sources": STATED_SOURCES, "utgave": "R900:2024", "merknad": "a=b"}
|
||||
[f"sources={STATED_SOURCES}", "utgave=P900:2024", "merknad=a=b"]
|
||||
) == {"sources": STATED_SOURCES, "utgave": "P900:2024", "merknad": "a=b"}
|
||||
|
||||
|
||||
def test_a_flag_without_an_equals_sign_is_refused() -> None:
|
||||
|
|
@ -125,7 +125,7 @@ def test_every_concept_carries_the_stated_keys_once(tmp_path: Path) -> None:
|
|||
_inbox(tmp_path),
|
||||
bundle,
|
||||
"--frontmatter",
|
||||
"utgave=R900:2024",
|
||||
"utgave=P900:2024",
|
||||
"--frontmatter",
|
||||
f"sources={WRITABLE_SOURCES}",
|
||||
)
|
||||
|
|
@ -137,7 +137,7 @@ def test_every_concept_carries_the_stated_keys_once(tmp_path: Path) -> None:
|
|||
)
|
||||
for path in concepts:
|
||||
lines = _frontmatter_lines(path)
|
||||
assert lines.count("utgave: R900:2024") == 1, path
|
||||
assert lines.count("utgave: P900:2024") == 1, path
|
||||
# ONE `sources` line, and it is the stated one: the flag REPLACES what
|
||||
# the door would derive -- the document's own title on the STS file,
|
||||
# the file name on the markdown one -- and never adds a second.
|
||||
|
|
@ -154,7 +154,7 @@ def test_the_stated_address_reads_back_through_this_packages_own_readers(
|
|||
for path in _concept_files(bundle):
|
||||
assert parse_frontmatter(path)["sources"] == WRITABLE_SOURCES
|
||||
assert read_sources(_frontmatter_lines(path)) == (
|
||||
({"resource": WRITABLE_ADDRESS, "title": "R900:2024"},),
|
||||
({"resource": WRITABLE_ADDRESS, "title": "P900:2024"},),
|
||||
True,
|
||||
)
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ def test_the_flag_adds_its_line_and_moves_nothing_else(tmp_path: Path) -> None:
|
|||
inbox = _inbox(tmp_path)
|
||||
plain, stamped = tmp_path / "plain", tmp_path / "stamped"
|
||||
assert _main(inbox, plain) == 0
|
||||
assert _main(inbox, stamped, "--frontmatter", "utgave=R900:2024") == 0
|
||||
assert _main(inbox, stamped, "--frontmatter", "utgave=P900:2024") == 0
|
||||
|
||||
before = {
|
||||
p.relative_to(plain).as_posix(): p.read_text(encoding="utf-8")
|
||||
|
|
@ -180,18 +180,18 @@ def test_the_flag_adds_its_line_and_moves_nothing_else(tmp_path: Path) -> None:
|
|||
moved = [name for name in before if before[name] != after[name]]
|
||||
assert moved, "the flag must reach at least one concept for this control to mean anything"
|
||||
for name in moved:
|
||||
assert after[name].replace("utgave: R900:2024\n", "", 1) == before[name], name
|
||||
assert after[name].replace("utgave: P900:2024\n", "", 1) == before[name], name
|
||||
|
||||
|
||||
def test_the_unsegmented_route_carries_them_too(tmp_path: Path) -> None:
|
||||
bundle = tmp_path / "bundle"
|
||||
assert (
|
||||
_main(_inbox(tmp_path), bundle, "--segments", "off", "--frontmatter", "utgave=R900:2024")
|
||||
_main(_inbox(tmp_path), bundle, "--segments", "off", "--frontmatter", "utgave=P900:2024")
|
||||
== 0
|
||||
)
|
||||
concepts = _concept_files(bundle)
|
||||
assert concepts
|
||||
assert all(parse_frontmatter(path)["utgave"] == "R900:2024" for path in concepts)
|
||||
assert all(parse_frontmatter(path)["utgave"] == "P900:2024" for path in concepts)
|
||||
|
||||
|
||||
# --- what is refused, before anything is written -----------------------------
|
||||
|
|
@ -258,7 +258,7 @@ def test_a_value_spanning_lines_is_refused_through_the_api(tmp_path: Path) -> No
|
|||
tmp_path / "bundle",
|
||||
bundle_id="run",
|
||||
okf_version="0.2",
|
||||
frontmatter={"utgave": "R900\nsources: [{ resource: x }]"},
|
||||
frontmatter={"utgave": "P900\nsources: [{ resource: x }]"},
|
||||
)
|
||||
assert caught.value.code == "run_frontmatter_invalid"
|
||||
assert not (tmp_path / "bundle").exists()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue