@@ -68,6 +68,13 @@ def sample_docx_path(self):
6868
6969 return os .path .join (os .path .dirname (__file__ ), ".." , "data" , "sample.docx" )
7070
71+ @pytest .fixture
72+ def sample_multipage_pdf_path (self ):
73+ """Get path to multi-page sample PDF file for testing."""
74+ import os
75+
76+ return os .path .join (os .path .dirname (__file__ ), ".." , "data" , "sample_multipage.pdf" )
77+
7178 # Tests for convert_to_pdf
7279 def test_convert_to_pdf_from_docx (self , client , sample_docx_path ):
7380 """Test convert_to_pdf method with DOCX input."""
@@ -244,16 +251,16 @@ def test_merge_pdfs_error_single_file(self, client, sample_pdf_path):
244251 client .merge_pdfs ([sample_pdf_path ])
245252
246253 # Tests for split_pdf
247- def test_split_pdf_integration (self , client , sample_pdf_path , tmp_path ):
254+ def test_split_pdf_integration (self , client , sample_multipage_pdf_path , tmp_path ):
248255 """Test split_pdf method with live API."""
249- # Test splitting PDF into two parts - sample PDF should have multiple pages
256+ # Test splitting PDF into two parts - multi-page PDF has 3 pages
250257 page_ranges = [
251258 {"start" : 0 , "end" : 1 }, # First page
252259 {"start" : 1 }, # Remaining pages
253260 ]
254261
255262 # Test getting bytes back
256- result = client .split_pdf (sample_pdf_path , page_ranges = page_ranges )
263+ result = client .split_pdf (sample_multipage_pdf_path , page_ranges = page_ranges )
257264
258265 assert isinstance (result , list )
259266 assert len (result ) == 2 # Should return exactly 2 parts
@@ -264,7 +271,7 @@ def test_split_pdf_integration(self, client, sample_pdf_path, tmp_path):
264271 for pdf_bytes in result :
265272 assert_is_pdf (pdf_bytes )
266273
267- def test_split_pdf_with_output_files (self , client , sample_pdf_path , tmp_path ):
274+ def test_split_pdf_with_output_files (self , client , sample_multipage_pdf_path , tmp_path ):
268275 """Test split_pdf method saving to output files."""
269276 output_paths = [str (tmp_path / "page1.pdf" ), str (tmp_path / "remaining.pdf" )]
270277
@@ -275,7 +282,7 @@ def test_split_pdf_with_output_files(self, client, sample_pdf_path, tmp_path):
275282
276283 # Test saving to files
277284 result = client .split_pdf (
278- sample_pdf_path , page_ranges = page_ranges , output_paths = output_paths
285+ sample_multipage_pdf_path , page_ranges = page_ranges , output_paths = output_paths
279286 )
280287
281288 # Should return empty list when saving to files
@@ -316,29 +323,29 @@ def test_split_pdf_too_many_ranges_error(self, client, sample_pdf_path):
316323 # Tests for duplicate_pdf_pages
317324 def test_duplicate_pdf_pages_basic (self , client , sample_pdf_path ):
318325 """Test duplicate_pdf_pages method with basic duplication."""
319- # Test duplicating first page twice
326+ # Test duplicating first page twice (works with single-page PDF)
320327 result = client .duplicate_pdf_pages (sample_pdf_path , page_indexes = [0 , 0 ])
321328
322329 assert isinstance (result , bytes )
323330 assert len (result ) > 0
324331 assert_is_pdf (result )
325332
326- def test_duplicate_pdf_pages_reorder (self , client , sample_pdf_path ):
333+ def test_duplicate_pdf_pages_reorder (self , client , sample_multipage_pdf_path ):
327334 """Test duplicate_pdf_pages method with page reordering."""
328- # Test reordering pages (assumes sample PDF has at least 2 pages)
329- result = client .duplicate_pdf_pages (sample_pdf_path , page_indexes = [1 , 0 ])
335+ # Test reordering pages (multi-page PDF has 3 pages)
336+ result = client .duplicate_pdf_pages (sample_multipage_pdf_path , page_indexes = [1 , 0 ])
330337
331338 assert isinstance (result , bytes )
332339 assert len (result ) > 0
333340 assert_is_pdf (result )
334341
335- def test_duplicate_pdf_pages_with_output_file (self , client , sample_pdf_path , tmp_path ):
342+ def test_duplicate_pdf_pages_with_output_file (self , client , sample_multipage_pdf_path , tmp_path ):
336343 """Test duplicate_pdf_pages method saving to output file."""
337344 output_path = str (tmp_path / "duplicated.pdf" )
338345
339- # Test duplicating and saving to file
346+ # Test duplicating and saving to file (multi-page PDF has 3 pages)
340347 result = client .duplicate_pdf_pages (
341- sample_pdf_path , page_indexes = [0 , 0 , 1 ], output_path = output_path
348+ sample_multipage_pdf_path , page_indexes = [0 , 0 , 1 ], output_path = output_path
342349 )
343350
344351 # Should return None when saving to file
@@ -351,7 +358,7 @@ def test_duplicate_pdf_pages_with_output_file(self, client, sample_pdf_path, tmp
351358
352359 def test_duplicate_pdf_pages_negative_indexes (self , client , sample_pdf_path ):
353360 """Test duplicate_pdf_pages method with negative indexes."""
354- # Test using negative indexes (last page)
361+ # Test using negative indexes (last page - works with single-page PDF )
355362 result = client .duplicate_pdf_pages (sample_pdf_path , page_indexes = [- 1 , 0 , - 1 ])
356363
357364 assert isinstance (result , bytes )
@@ -364,30 +371,30 @@ def test_duplicate_pdf_pages_empty_indexes_error(self, client, sample_pdf_path):
364371 client .duplicate_pdf_pages (sample_pdf_path , page_indexes = [])
365372
366373 # Tests for delete_pdf_pages
367- def test_delete_pdf_pages_basic (self , client , sample_pdf_path ):
374+ def test_delete_pdf_pages_basic (self , client , sample_multipage_pdf_path ):
368375 """Test delete_pdf_pages method with basic page deletion."""
369- # Test deleting first page (assuming sample PDF has at least 2 pages)
370- result = client .delete_pdf_pages (sample_pdf_path , page_indexes = [0 ])
376+ # Test deleting first page (multi-page PDF has 3 pages)
377+ result = client .delete_pdf_pages (sample_multipage_pdf_path , page_indexes = [0 ])
371378
372379 assert isinstance (result , bytes )
373380 assert len (result ) > 0
374381 assert_is_pdf (result )
375382
376- def test_delete_pdf_pages_multiple (self , client , sample_pdf_path ):
383+ def test_delete_pdf_pages_multiple (self , client , sample_multipage_pdf_path ):
377384 """Test delete_pdf_pages method with multiple page deletion."""
378- # Test deleting multiple pages
379- result = client .delete_pdf_pages (sample_pdf_path , page_indexes = [0 , 2 ])
385+ # Test deleting multiple pages (deleting pages 1 and 3 from 3-page PDF)
386+ result = client .delete_pdf_pages (sample_multipage_pdf_path , page_indexes = [0 , 2 ])
380387
381388 assert isinstance (result , bytes )
382389 assert len (result ) > 0
383390 assert_is_pdf (result )
384391
385- def test_delete_pdf_pages_with_output_file (self , client , sample_pdf_path , tmp_path ):
392+ def test_delete_pdf_pages_with_output_file (self , client , sample_multipage_pdf_path , tmp_path ):
386393 """Test delete_pdf_pages method saving to output file."""
387394 output_path = str (tmp_path / "pages_deleted.pdf" )
388395
389396 # Test deleting pages and saving to file
390- result = client .delete_pdf_pages (sample_pdf_path , page_indexes = [1 ], output_path = output_path )
397+ result = client .delete_pdf_pages (sample_multipage_pdf_path , page_indexes = [1 ], output_path = output_path )
391398
392399 # Should return None when saving to file
393400 assert result is None
@@ -408,10 +415,10 @@ def test_delete_pdf_pages_empty_indexes_error(self, client, sample_pdf_path):
408415 with pytest .raises (ValueError , match = "page_indexes cannot be empty" ):
409416 client .delete_pdf_pages (sample_pdf_path , page_indexes = [])
410417
411- def test_delete_pdf_pages_duplicate_indexes (self , client , sample_pdf_path ):
418+ def test_delete_pdf_pages_duplicate_indexes (self , client , sample_multipage_pdf_path ):
412419 """Test delete_pdf_pages method with duplicate page indexes."""
413420 # Test that duplicate indexes are handled correctly (should remove duplicates)
414- result = client .delete_pdf_pages (sample_pdf_path , page_indexes = [0 , 0 , 1 ])
421+ result = client .delete_pdf_pages (sample_multipage_pdf_path , page_indexes = [0 , 0 , 1 ])
415422
416423 assert isinstance (result , bytes )
417424 assert len (result ) > 0
@@ -427,10 +434,10 @@ def test_add_page_at_beginning(self, client, sample_pdf_path):
427434 assert len (result ) > 0
428435 assert_is_pdf (result )
429436
430- def test_add_page_multiple_pages (self , client , sample_pdf_path ):
437+ def test_add_page_multiple_pages (self , client , sample_multipage_pdf_path ):
431438 """Test add_page method with multiple pages."""
432439 # Test adding multiple blank pages before second page
433- result = client .add_page (sample_pdf_path , insert_index = 1 , page_count = 3 )
440+ result = client .add_page (sample_multipage_pdf_path , insert_index = 1 , page_count = 3 )
434441
435442 assert isinstance (result , bytes )
436443 assert len (result ) > 0
@@ -445,10 +452,10 @@ def test_add_page_at_end(self, client, sample_pdf_path):
445452 assert len (result ) > 0
446453 assert_is_pdf (result )
447454
448- def test_add_page_before_specific_page (self , client , sample_pdf_path ):
455+ def test_add_page_before_specific_page (self , client , sample_multipage_pdf_path ):
449456 """Test add_page method inserting before a specific page."""
450457 # Test inserting before page 3 (insert_index=2)
451- result = client .add_page (sample_pdf_path , insert_index = 2 , page_count = 1 )
458+ result = client .add_page (sample_multipage_pdf_path , insert_index = 2 , page_count = 1 )
452459
453460 assert isinstance (result , bytes )
454461 assert len (result ) > 0
@@ -469,13 +476,13 @@ def test_add_page_custom_size_orientation(self, client, sample_pdf_path):
469476 assert len (result ) > 0
470477 assert_is_pdf (result )
471478
472- def test_add_page_with_output_file (self , client , sample_pdf_path , tmp_path ):
479+ def test_add_page_with_output_file (self , client , sample_multipage_pdf_path , tmp_path ):
473480 """Test add_page method saving to output file."""
474481 output_path = str (tmp_path / "with_blank_pages.pdf" )
475482
476483 # Test adding pages and saving to file
477484 result = client .add_page (
478- sample_pdf_path , insert_index = 1 , page_count = 2 , output_path = output_path
485+ sample_multipage_pdf_path , insert_index = 1 , page_count = 2 , output_path = output_path
479486 )
480487
481488 # Should return None when saving to file
@@ -547,15 +554,15 @@ def test_set_page_label_return_bytes(self, client, sample_pdf_path):
547554 assert len (result ) > 0
548555 assert_is_pdf (result )
549556
550- def test_set_page_label_multiple_ranges (self , client , sample_pdf_path ):
557+ def test_set_page_label_multiple_ranges (self , client , sample_multipage_pdf_path ):
551558 """Test set_page_label method with multiple page ranges."""
552559 labels = [
553560 {"pages" : {"start" : 0 , "end" : 1 }, "label" : "i" },
554561 {"pages" : {"start" : 1 , "end" : 2 }, "label" : "intro" },
555562 {"pages" : {"start" : 2 , "end" : 3 }, "label" : "final" },
556563 ]
557564
558- result = client .set_page_label (sample_pdf_path , labels )
565+ result = client .set_page_label (sample_multipage_pdf_path , labels )
559566
560567 assert isinstance (result , bytes )
561568 assert len (result ) > 0
0 commit comments