darachhat
feat: build production-ready Khmer Document Corpus v0.2.0 with Typer CLI, PyMuPDF, Polars, and DI architecture
c4e128a
Raw
History Blame Contribute Delete
1.15 kB
"""Pytest shared fixtures."""
from __future__ import annotations
from pathlib import Path
import fitz # PyMuPDF
import pytest
from app.models.document import Category, DocumentMeta, Language
@pytest.fixture
def temp_dir(tmp_path: Path) -> Path:
return tmp_path
@pytest.fixture
def sample_pdf(tmp_path: Path) -> Path:
"""Create a minimal 2-page synthetic PDF document for testing."""
pdf_path = tmp_path / "sample.pdf"
doc = fitz.open()
# Page 1: Khmer text
page1 = doc.new_page(width=595, height=842)
page1.insert_text((50, 50), "ភាសាខ្មែរ Khmer Document Corpus Test Page 1")
# Page 2: English text
page2 = doc.new_page(width=595, height=842)
page2.insert_text((50, 50), "This is page 2 with English text.")
doc.save(str(pdf_path))
doc.close()
return pdf_path
@pytest.fixture
def sample_meta() -> DocumentMeta:
return DocumentMeta(
filename="test.pdf",
language=Language.mixed,
category=Category.research_paper,
pages=2,
file_size_bytes=2048,
native_pdf=True,
scanned=False,
sha256="a" * 64,
)