11"""Comprehensive unit tests for Direct API methods."""
22
33import tempfile
4+ from typing import BinaryIO , cast
45from unittest .mock import Mock , patch
56
67import pytest
@@ -195,9 +196,9 @@ def test_merge_pdfs_returns_bytes(self, mock_save, mock_prepare):
195196 ]
196197
197198 # Mock HTTP client
198- self .client ._http_client .post = Mock (return_value = self .mock_response )
199+ self .client ._http_client .post = Mock (return_value = self .mock_response ) # type: ignore
199200
200- result = self .client .merge_pdfs (["file1.pdf" , "file2.pdf" ])
201+ result = self .client .merge_pdfs (["file1.pdf" , "file2.pdf" ]) # type: ignore[arg-type]
201202
202203 assert result == self .mock_response
203204 assert mock_prepare .call_count == 2
@@ -221,7 +222,7 @@ def test_merge_pdfs_saves_to_file(self, mock_save, mock_prepare):
221222 ]
222223
223224 # Mock HTTP client
224- self .client ._http_client .post = Mock (return_value = self .mock_response )
225+ self .client ._http_client .post = Mock (return_value = self .mock_response ) # type: ignore
225226
226227 result = self .client .merge_pdfs (["file1.pdf" , "file2.pdf" ], "merged.pdf" )
227228
@@ -247,10 +248,10 @@ def test_merge_pdfs_multiple_files(self, mock_prepare):
247248 ]
248249
249250 # Mock HTTP client
250- self .client ._http_client .post = Mock (return_value = self .mock_response )
251+ self .client ._http_client .post = Mock (return_value = self .mock_response ) # type: ignore
251252
252253 files = ["file1.pdf" , "file2.pdf" , "file3.pdf" ]
253- result = self .client .merge_pdfs (files )
254+ result = self .client .merge_pdfs (files ) # type: ignore[arg-type]
254255
255256 assert result == self .mock_response
256257 assert mock_prepare .call_count == 3
@@ -298,8 +299,8 @@ def test_direct_api_with_file_like_object(self, mock_process):
298299 temp_file .write (b"test content" )
299300 temp_file .seek (0 )
300301
301- self .client .rotate_pages (temp_file , degrees = 90 )
302- mock_process .assert_called_once_with ("rotate-pages" , temp_file , None , degrees = 90 )
302+ self .client .rotate_pages (cast ( BinaryIO , temp_file ) , degrees = 90 )
303+ mock_process .assert_called_once_with ("rotate-pages" , cast ( BinaryIO , temp_file ) , None , degrees = 90 )
303304
304305
305306class TestDirectAPIErrorHandling :
@@ -456,9 +457,9 @@ def test_merge_pdfs_maximum_files(self, mock_prepare):
456457 ]
457458
458459 # Mock HTTP client
459- self .client ._http_client .post = Mock (return_value = b"merged_result" )
460+ self .client ._http_client .post = Mock (return_value = b"merged_result" ) # type: ignore
460461
461- result = self .client .merge_pdfs (files )
462+ result = self .client .merge_pdfs (files ) # type: ignore[arg-type]
462463
463464 assert result == b"merged_result"
464465 assert mock_prepare .call_count == 10
0 commit comments