Chore: Use shared samples in tests that arrived from dev

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Trenton HandClaude Sonnet 5.5 committed 2026-10-22 10:45:33 -07:00
1 parent 82c4a8d397
commit 99320c2aea
5 files changed
+27 -23

No files matched your search

@@ -828,10 +828,7 @@ class TestExportImport(
def _export_import_barcodes(self, *, split_manifest: bool) -> None:
shutil.rmtree(Path(self.dirs.media_dir) / "documents")
shutil.copytree(
Path(__file__).parent / "samples" / "documents",
Path(self.dirs.media_dir) / "documents",
)
install_document_samples(Path(self.dirs.media_dir) / "documents")
DocumentBarcodeFactory(document=self.d1, value="https://example.com")
DocumentBarcodeFactory(document=self.d2, page=2, value="DE8937")
+1 -8
View File
@@ -279,14 +279,7 @@ class TestUpdateContent(DirectoriesMixin, TestCase):
def _create_root_with_version(self) -> tuple[Document, Document]:
sample1 = self.dirs.scratch_dir / "sample.pdf"
shutil.copy(
Path(__file__).parent
/ "samples"
/ "documents"
/ "originals"
/ "0000001.pdf",
sample1,
)
shutil.copy(SIMPLE_DIGITAL_PDF, sample1)
root = DocumentFactory(content="root content", mime_type="application/pdf")
version = DocumentFactory(
content="my document",
+12
View File
@@ -456,6 +456,18 @@ def simple_png_file(tesseract_samples_dir: Path) -> Path:
return tesseract_samples_dir / "simple.png"
@pytest.fixture(scope="session")
def rotated_pdf_file(tesseract_samples_dir: Path) -> Path:
"""Path to a landscape (rotated) PDF sample file.
Returns
-------
Path
Absolute path to ``tesseract/rotated.pdf``.
"""
return tesseract_samples_dir / "rotated.pdf"
# ------------------------------------------------------------------
# Tesseract parser instance and settings helpers
# ------------------------------------------------------------------
@@ -282,17 +282,17 @@ class TestGetThumbnail:
assert thumb.is_file()
@pytest.mark.parametrize(
("filename", "expected_height"),
("sample_fixture", "expected_height"),
[
pytest.param("simple-digital.pdf", 647, id="portrait-letter"),
pytest.param("rotated.pdf", 386, id="landscape"),
pytest.param("simple_digital_pdf_file", 647, id="portrait-letter"),
pytest.param("rotated_pdf_file", 386, id="landscape"),
],
)
def test_thumbnail_is_correct_format_and_size(
self,
tesseract_parser: RasterisedDocumentParser,
tesseract_samples_dir: Path,
filename: str,
request: pytest.FixtureRequest,
sample_fixture: str,
expected_height: int,
) -> None:
"""
@@ -304,7 +304,7 @@ class TestGetThumbnail:
- A 500px wide WebP keeping the page's aspect ratio
"""
thumb = tesseract_parser.get_thumbnail(
tesseract_samples_dir / filename,
request.getfixturevalue(sample_fixture),
"application/pdf",
)
with Image.open(thumb) as im:
+7 -5
View File
@@ -93,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
@@ -102,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,
)
@@ -197,6 +197,7 @@ class TestGetPdfFirstPageSizePoints:
def test_pdfinfo_not_installed_returns_none(
self,
mocker: MockerFixture,
simple_digital_pdf_file: Path,
) -> None:
"""
GIVEN:
@@ -207,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:
"""
@@ -249,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
@@ -258,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: