Skip to content

Commit 86379cf

Browse files
Add integration tests for convert_to_pdf method (#7)
- Add 3 integration tests covering DOCX to PDF conversion - Add sample.docx test file for Office document testing - Test conversion to bytes, saving to file, and PDF passthrough - All tests verify output is valid PDF format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent b53470e commit 86379cf

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/data/sample.docx

2.19 MB
Binary file not shown.

tests/integration/test_live_api.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,47 @@ def test_delete_pdf_pages_duplicate_indexes(self, client, sample_pdf_path):
273273

274274
# Verify result is a valid PDF
275275
assert_is_pdf(result)
276+
277+
@pytest.fixture
278+
def sample_docx_path(self):
279+
"""Get path to sample DOCX file for testing."""
280+
import os
281+
282+
return os.path.join(os.path.dirname(__file__), "..", "data", "sample.docx")
283+
284+
def test_convert_to_pdf_from_docx(self, client, sample_docx_path):
285+
"""Test convert_to_pdf method with DOCX input."""
286+
# Test converting DOCX to PDF and getting bytes back
287+
result = client.convert_to_pdf(sample_docx_path)
288+
289+
assert isinstance(result, bytes)
290+
assert len(result) > 0
291+
292+
# Verify result is a valid PDF
293+
assert_is_pdf(result)
294+
295+
def test_convert_to_pdf_with_output_file(self, client, sample_docx_path, tmp_path):
296+
"""Test convert_to_pdf method saving to output file."""
297+
output_path = str(tmp_path / "converted.pdf")
298+
299+
# Test converting and saving to file
300+
result = client.convert_to_pdf(sample_docx_path, output_path=output_path)
301+
302+
# Should return None when saving to file
303+
assert result is None
304+
305+
# Check that output file was created
306+
assert (tmp_path / "converted.pdf").exists()
307+
assert (tmp_path / "converted.pdf").stat().st_size > 0
308+
assert_is_pdf(output_path)
309+
310+
def test_convert_to_pdf_from_pdf_passthrough(self, client, sample_pdf_path):
311+
"""Test convert_to_pdf method with PDF input (should pass through)."""
312+
# Test that PDF input passes through unchanged
313+
result = client.convert_to_pdf(sample_pdf_path)
314+
315+
assert isinstance(result, bytes)
316+
assert len(result) > 0
317+
318+
# Verify result is a valid PDF
319+
assert_is_pdf(result)

0 commit comments

Comments
 (0)