File size: 1,150 Bytes
c4e128a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""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,
    )