import os
import pytest
import unpdf
class TestVersion:
def test_version_returns_string(self):
ver = unpdf.version()
assert isinstance(ver, str)
assert len(ver) > 0
class TestIsPdf:
def test_non_existent_file(self):
assert unpdf.is_pdf("non_existent_file.pdf") is False
def test_non_pdf_file(self, tmp_path):
txt_file = tmp_path / "test.txt"
txt_file.write_text("This is not a PDF")
assert unpdf.is_pdf(str(txt_file)) is False
class TestGetPageCount:
def test_non_existent_file(self):
assert unpdf.get_page_count("non_existent_file.pdf") == -1
class TestToMarkdown:
def test_non_existent_file_raises(self):
with pytest.raises(RuntimeError):
unpdf.to_markdown("non_existent_file.pdf")
class TestToText:
def test_non_existent_file_raises(self):
with pytest.raises(RuntimeError):
unpdf.to_text("non_existent_file.pdf")
class TestToJson:
def test_non_existent_file_raises(self):
with pytest.raises(RuntimeError):
unpdf.to_json("non_existent_file.pdf")
class TestGetInfo:
def test_non_existent_file_raises(self):
with pytest.raises(RuntimeError):
unpdf.get_info("non_existent_file.pdf")