6f7cadfc63
- #1: check_preflight() prüft beim Start tesseract + gs, wirft PreflightError. CLI endet mit Exit 2 statt grün zu bleiben. - #2: run_once() gibt Anzahl fehlgeschlagener PDFs zurück, CLI endet mit Exit 1 wenn mindestens eine Datei scheiterte. - pytest-Suite mit 11 Tests für beide Szenarien - ocrmypdf-Import lazy in processor.py (Tests ohne ocrmypdf möglich) Closes #1, #2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
"""Gemeinsame pytest-Fixtures."""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from pdf_ocr_hotfolder.config import (
|
|
Config,
|
|
EmailNotify,
|
|
FolderUpload,
|
|
NextcloudUpload,
|
|
OcrConfig,
|
|
Paths,
|
|
SftpUpload,
|
|
VeraPdfConfig,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_config(tmp_path: Path) -> Config:
|
|
"""Minimal-Config mit tmp_path-Verzeichnissen, alle Uploads deaktiviert."""
|
|
paths = Paths(
|
|
incoming=tmp_path / "incoming",
|
|
outgoing=tmp_path / "outgoing",
|
|
working=tmp_path / "working",
|
|
error=tmp_path / "error",
|
|
)
|
|
for p in (paths.incoming, paths.outgoing, paths.working, paths.error):
|
|
p.mkdir(parents=True, exist_ok=True)
|
|
|
|
return Config(
|
|
paths=paths,
|
|
ocr=OcrConfig(max_workers=1),
|
|
verapdf=VeraPdfConfig(enabled=False),
|
|
folder=FolderUpload(enabled=False),
|
|
nextcloud=NextcloudUpload(enabled=False),
|
|
sftp=SftpUpload(enabled=False),
|
|
email=EmailNotify(enabled=False),
|
|
log_level="DEBUG",
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def dummy_pdf(tmp_config: Config) -> Path:
|
|
"""Legt eine Datei mit .pdf-Extension im incoming-Ordner ab.
|
|
|
|
Achtung: kein echtes PDF. Für Tests wird `process_pdf` gemockt.
|
|
"""
|
|
pdf = tmp_config.paths.incoming / "test.pdf"
|
|
pdf.write_bytes(b"%PDF-1.4 fake\n")
|
|
return pdf
|