feat(gui): DocResult porte type+catégorie d'erreur RGPD-safe (E2)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -261,3 +261,45 @@ def test_run_records_per_document_details(tmp_path):
|
||||
assert not hasattr(doc, "path")
|
||||
assert not hasattr(doc, "filename")
|
||||
assert not hasattr(doc, "name")
|
||||
|
||||
|
||||
# -- diagnostics d'erreur RGPD-safe (E2) -----------------------------------
|
||||
|
||||
def test_failed_doc_carries_rgpd_safe_error_fields(tmp_path):
|
||||
from gui_v6.processing_runner import ProcessingRunner
|
||||
|
||||
secret = "Dupont Jean 1980" # simulacre de PII dans un message d'exception
|
||||
|
||||
def boom(_inp, _out):
|
||||
raise ValueError(f"échec sur patient {secret}")
|
||||
|
||||
inp = tmp_path / "in"; inp.mkdir()
|
||||
(inp / "a.pdf").write_bytes(b"%PDF-1.4\n")
|
||||
out = tmp_path / "out"; out.mkdir()
|
||||
runner = ProcessingRunner(process_fn=boom)
|
||||
summary = runner.run(inp, out)
|
||||
|
||||
assert summary.failed == 1
|
||||
doc = summary.documents[0]
|
||||
assert doc.error_type == "ValueError"
|
||||
assert doc.error_code in {"ner_unavailable", "quarantined", "no_output", "processing_error"}
|
||||
blob = repr(vars(doc)).lower()
|
||||
assert "dupont" not in blob and "patient" not in blob and secret.lower() not in blob
|
||||
|
||||
|
||||
def test_success_doc_has_no_error_fields(tmp_path):
|
||||
from gui_v6.processing_runner import ProcessingRunner
|
||||
|
||||
def ok(_inp, out_dir):
|
||||
# process_fn reçoit le DOSSIER de sortie : on y écrit un PDF livrable.
|
||||
pdf = out_dir / "a.redacted_raster.pdf"
|
||||
pdf.write_bytes(b"%PDF-1.4\n")
|
||||
return {"status": "ok", "pdf_raster": str(pdf)}
|
||||
|
||||
inp = tmp_path / "in"; inp.mkdir()
|
||||
(inp / "a.pdf").write_bytes(b"%PDF-1.4\n")
|
||||
out = tmp_path / "out"; out.mkdir()
|
||||
summary = ProcessingRunner(process_fn=ok).run(inp, out)
|
||||
doc = summary.documents[0]
|
||||
assert doc.status == "success"
|
||||
assert doc.error_type is None and doc.error_code is None
|
||||
|
||||
Reference in New Issue
Block a user