mirror of
https://github.com/docling-project/docling.git
synced 2025-06-27 05:20:05 +00:00

* add coverage calculation and push Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * new codecov version and usage of token Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * enable ruff formatter instead of black and isort Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * apply ruff lint fixes Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * apply ruff unsafe fixes Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * add removed imports Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * runs 1 on linter issues Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * finalize linter fixes Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * Update pyproject.toml Co-authored-by: Cesar Berrospi Ramis <75900930+ceberam@users.noreply.github.com> Signed-off-by: Michele Dolfi <97102151+dolfim-ibm@users.noreply.github.com> --------- Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> Signed-off-by: Michele Dolfi <97102151+dolfim-ibm@users.noreply.github.com> Co-authored-by: Cesar Berrospi Ramis <75900930+ceberam@users.noreply.github.com>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
from io import BytesIO
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from docling.datamodel.base_models import ConversionStatus, DocumentStream
|
|
from docling.document_converter import ConversionError, DocumentConverter
|
|
|
|
|
|
def get_pdf_path():
|
|
pdf_path = Path("./tests/data/pdf/2305.03393v1-pg9.pdf")
|
|
return pdf_path
|
|
|
|
|
|
@pytest.fixture
|
|
def converter():
|
|
converter = DocumentConverter()
|
|
|
|
return converter
|
|
|
|
|
|
def test_convert_unsupported_doc_format_wout_exception(converter: DocumentConverter):
|
|
result = converter.convert(
|
|
DocumentStream(name="input.xyz", stream=BytesIO(b"xyz")), raises_on_error=False
|
|
)
|
|
assert result.status == ConversionStatus.SKIPPED
|
|
|
|
|
|
def test_convert_unsupported_doc_format_with_exception(converter: DocumentConverter):
|
|
with pytest.raises(ConversionError):
|
|
converter.convert(
|
|
DocumentStream(name="input.xyz", stream=BytesIO(b"xyz")),
|
|
raises_on_error=True,
|
|
)
|
|
|
|
|
|
def test_convert_too_small_filesize_limit_wout_exception(converter: DocumentConverter):
|
|
result = converter.convert(get_pdf_path(), max_file_size=1, raises_on_error=False)
|
|
assert result.status == ConversionStatus.FAILURE
|
|
|
|
|
|
def test_convert_too_small_filesize_limit_with_exception(converter: DocumentConverter):
|
|
with pytest.raises(ConversionError):
|
|
converter.convert(get_pdf_path(), max_file_size=1, raises_on_error=True)
|