mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-04-15 20:48:53 +00:00
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
26 lines
812 B
Python
26 lines
812 B
Python
"""Tests for paperless.parsers.utils helpers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from paperless.parsers.utils import is_tagged_pdf
|
|
|
|
SAMPLES = Path(__file__).parent / "samples" / "tesseract"
|
|
|
|
|
|
class TestIsTaggedPdf:
|
|
def test_tagged_pdf_returns_true(self) -> None:
|
|
assert is_tagged_pdf(SAMPLES / "simple-digital.pdf") is True
|
|
|
|
def test_untagged_pdf_returns_false(self) -> None:
|
|
assert is_tagged_pdf(SAMPLES / "multi-page-images.pdf") is False
|
|
|
|
def test_nonexistent_path_returns_false(self) -> None:
|
|
assert is_tagged_pdf(Path("/nonexistent/file.pdf")) is False
|
|
|
|
def test_corrupt_pdf_returns_false(self, tmp_path: Path) -> None:
|
|
bad = tmp_path / "bad.pdf"
|
|
bad.write_bytes(b"not a pdf")
|
|
assert is_tagged_pdf(bad) is False
|