1import json, pandas as pd2from jof250 import inventory, provenance34def test_sha256_and_duplicates(tmp_path, synthetic_pdf):5 dup = tmp_path / "copy.pdf"; dup.write_bytes(synthetic_pdf.read_bytes())6 (tmp_path / "notes.txt").write_text("not a pdf")7 df = inventory.scan(tmp_path)8 assert len(df) == 3 and df.sha256.nunique() == 29 assert provenance.sha256_file(synthetic_pdf) == provenance.sha256_file(dup)10 assert df[df.ext == ".pdf"].pdf_valid.all()1112def test_pdf_probe_extracts_doi(synthetic_pdf):13 r = inventory.pdf_probe(synthetic_pdf); assert r["pages"] == 1 and r["doi_in_pdf"] == "10.1111/jofi.99999"1415def test_classify_excludes_non_pdf_and_duplicates(tmp_path, synthetic_pdf, monkeypatch):16 dup = tmp_path / "copy.pdf"; dup.write_bytes(synthetic_pdf.read_bytes()); (tmp_path / "x.csv").write_text("a")17 df = inventory.scan(tmp_path); df["bib_doi"] = "10.1111/jofi.99999"; df["bib_year"] = 2018; df["bib_section"] = "ARTICLES"; df["bib_title"] = "A Synthetic Test Article"; df["bib_joined"] = True18 out = inventory.classify(df)19 assert (out.decision == "exclude").sum() == 3 # csv + 2 identical PDFs (both flagged as duplicate content)20 assert "non-PDF file" in set(out.decision_reason)2122def test_frozen_manifest_exists_and_counts_match():23 from jof250 import config24 p = config.manifests_dir() / "corpus_v1_frozen.json"25 if not p.exists(): import pytest; pytest.skip("real corpus not audited on this machine")26 fz = json.loads(p.read_text()); man = pd.read_parquet(config.manifests_dir() / "corpus_manifest.parquet")27 assert fz["n_included"] == int((man.decision == "include").sum()) == len(fz["documents"])28