Skip to content

A fast, helpful, and open-source document parser

chore: some more tests

Clelia (Astra) Bertellibfc75844be7f
diff --git a/packages/python/tests/test_batch_e2e.py b/packages/python/tests/test_batch_e2e.py
index 72319cb..88f72b2 100644
--- a/packages/python/tests/test_batch_e2e.py
+++ b/packages/python/tests/test_batch_e2e.py
@@ -80,3 +80,9 @@ class TestBatchParseErrors:
with tempfile.TemporaryDirectory() as tmpdir:
with pytest.raises(FileNotFoundError):
parser.batch_parse("/nonexistent/dir", tmpdir)
+
+ @pytest.mark.asyncio
+ async def test_input_dir_not_found_async(self, parser: LiteParse):
+ with tempfile.TemporaryDirectory() as tmpdir:
+ with pytest.raises(FileNotFoundError):
+ await parser.batch_parse_async("/nonexistent/dir", tmpdir)
diff --git a/packages/python/tests/test_parse_e2e.py b/packages/python/tests/test_parse_e2e.py
index 0c65d50..4546a91 100644
--- a/packages/python/tests/test_parse_e2e.py
+++ b/packages/python/tests/test_parse_e2e.py
@@ -157,3 +157,20 @@ class TestParseErrors:
# Extremely short timeout should fail
with pytest.raises(TimeoutError):
parser.parse(invoice_pdf, timeout=0.001)
+
+ @pytest.mark.asyncio
+ async def test_file_not_found_async(self, parser: LiteParse):
+ with pytest.raises(FileNotFoundError):
+ await parser.parse_async("/nonexistent/file.pdf")
+
+ @pytest.mark.asyncio
+ async def test_cli_not_found_async(self):
+ parser = LiteParse(cli_path="/nonexistent/liteparse")
+ # subprocess raises FileNotFoundError when the binary doesn't exist
+ with pytest.raises((ParseError, FileNotFoundError, OSError)):
+ parser.parse(Path(__file__)) # any existing file
+
+ @pytest.mark.asyncio
+ async def test_timeout_async(self, parser: LiteParse, invoice_pdf: Path):
+ with pytest.raises(TimeoutError):
+ await parser.parse_async(invoice_pdf, timeout=0.001)
diff --git a/packages/python/tests/test_screenshot_e2e.py b/packages/python/tests/test_screenshot_e2e.py
index f089b85..18f8898 100644
--- a/packages/python/tests/test_screenshot_e2e.py
+++ b/packages/python/tests/test_screenshot_e2e.py
@@ -54,6 +54,12 @@ class TestScreenshotBasic:
for ss in result.screenshots:
assert ss.image_path.endswith(".jpg")
+ @pytest.mark.asyncio
+ async def test_screensho_async_basic(self, parser: LiteParse, invoice_pdf: Path):
+ result = await parser.screenshot_async(invoice_pdf, image_format="png")
+ assert isinstance(result, ScreenshotBatchResult)
+ assert len(result.screenshots) > 0
+
class TestScreenshotOptions:
"""Test screenshot options are forwarded correctly."""