DealDocumentScreening/tests/unit/test_extractor.py
2026-08-12 21:29:36 +03:00

25 lines
783 B
Python

"""Extractor unit tests — error paths only (real extraction is integration)."""
from __future__ import annotations
from pathlib import Path
import pytest
from contract_check.core.analysis.extractor import SUPPORTED_SUFFIXES, ExtractionError, extract_text
def test_missing_file_raises(tmp_path: Path) -> None:
with pytest.raises(ExtractionError, match="не найден"):
extract_text(tmp_path / "nope.pdf")
def test_unsupported_suffix_raises(tmp_path: Path) -> None:
f = tmp_path / "contract.txt"
f.write_text("hello" * 50)
with pytest.raises(ExtractionError, match="Неподдерживаемый формат"):
extract_text(f)
def test_supported_suffixes_cover_pdf_docx() -> None:
assert {".pdf", ".docx"} <= SUPPORTED_SUFFIXES