mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-12-04 10:14:24 +00:00
Chore: Consolidate test sample files (#14430)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
47052d6506
commit
08a7d1d4b8
43 files changed
+319
-355
No files matched your search
@@ -18,8 +18,6 @@ from paperless.parsers.utils import read_file_handle_unicode_errors
|
||||
if TYPE_CHECKING:
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
SAMPLES = Path(__file__).parent / "samples" / "tesseract"
|
||||
|
||||
|
||||
class TestReadFileHandleUnicodeErrors:
|
||||
def test_plain_utf8(self, tmp_path: Path) -> None:
|
||||
@@ -57,11 +55,11 @@ class TestReadFileHandleUnicodeErrors:
|
||||
|
||||
|
||||
class TestIsTaggedPdf:
|
||||
def test_tagged_pdf_returns_true(self) -> None:
|
||||
assert is_tagged_pdf(SAMPLES / "simple-digital.pdf") is True
|
||||
def test_tagged_pdf_returns_true(self, simple_digital_pdf_file: Path) -> None:
|
||||
assert is_tagged_pdf(simple_digital_pdf_file) is True
|
||||
|
||||
def test_untagged_pdf_returns_false(self) -> None:
|
||||
assert is_tagged_pdf(SAMPLES / "multi-page-images.pdf") is False
|
||||
def test_untagged_pdf_returns_false(self, multi_page_images_pdf_file: Path) -> None:
|
||||
assert is_tagged_pdf(multi_page_images_pdf_file) is False
|
||||
|
||||
def test_nonexistent_path_returns_false(self) -> None:
|
||||
assert is_tagged_pdf(Path("/nonexistent/file.pdf")) is False
|
||||
@@ -95,7 +93,7 @@ class TestGetPdfFirstPageSizePoints:
|
||||
pdf.save(path)
|
||||
return path
|
||||
|
||||
def test_letter_sample(self) -> None:
|
||||
def test_letter_sample(self, simple_digital_pdf_file: Path) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- A US Letter sample PDF with no CropBox and no rotation
|
||||
@@ -104,7 +102,7 @@ class TestGetPdfFirstPageSizePoints:
|
||||
THEN:
|
||||
- The MediaBox size in points is returned
|
||||
"""
|
||||
assert get_pdf_first_page_size_points(SAMPLES / "simple-digital.pdf") == (
|
||||
assert get_pdf_first_page_size_points(simple_digital_pdf_file) == (
|
||||
612.0,
|
||||
792.0,
|
||||
)
|
||||
@@ -199,6 +197,7 @@ class TestGetPdfFirstPageSizePoints:
|
||||
def test_pdfinfo_not_installed_returns_none(
|
||||
self,
|
||||
mocker: MockerFixture,
|
||||
simple_digital_pdf_file: Path,
|
||||
) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
@@ -209,7 +208,7 @@ class TestGetPdfFirstPageSizePoints:
|
||||
- None is returned and nothing is raised
|
||||
"""
|
||||
mocker.patch("subprocess.run", side_effect=FileNotFoundError("pdfinfo"))
|
||||
assert get_pdf_first_page_size_points(SAMPLES / "simple-digital.pdf") is None
|
||||
assert get_pdf_first_page_size_points(simple_digital_pdf_file) is None
|
||||
|
||||
def test_degenerate_box_returns_none(self, tmp_path: Path) -> None:
|
||||
"""
|
||||
@@ -251,7 +250,7 @@ class TestGetPdfFirstPageSizePoints:
|
||||
bad.write_bytes(b"not a pdf")
|
||||
assert get_pdf_first_page_size_points(bad) is None
|
||||
|
||||
def test_encrypted_pdf_returns_none(self) -> None:
|
||||
def test_encrypted_pdf_returns_none(self, parser_samples_dir: Path) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- A password protected PDF
|
||||
@@ -260,7 +259,8 @@ class TestGetPdfFirstPageSizePoints:
|
||||
THEN:
|
||||
- None is returned and nothing is raised
|
||||
"""
|
||||
assert get_pdf_first_page_size_points(SAMPLES / "encrypted.pdf") is None
|
||||
encrypted = parser_samples_dir / "tesseract" / "encrypted.pdf"
|
||||
assert get_pdf_first_page_size_points(encrypted) is None
|
||||
|
||||
|
||||
class TestPostProcessText:
|
||||
|
||||
Reference in new issue
Block a user