@@ -297,18 +297,17 @@ async def test_async_blank_pdf_page_count_boundaries_validation(
297297
298298
299299@pytest .mark .parametrize (
300- ("custom_height" , "custom_width " , "match" ),
300+ ("page_size " , "match" ),
301301 [
302- pytest .param (0.0 , 10.0 , "greater than 0" , id = "height-zero" ),
303- pytest .param (- 1.0 , 10.0 , "greater than 0" , id = "height-negative" ),
304- pytest .param (10.0 , 0.0 , "greater than 0" , id = "width-zero" ),
305- pytest .param (10.0 , - 1.0 , "greater than 0" , id = "width-negative" ),
302+ pytest .param (( 0.0 , 10.0 ) , "greater than 0" , id = "height-zero" ),
303+ pytest .param (( - 1.0 , 10.0 ) , "greater than 0" , id = "height-negative" ),
304+ pytest .param (( 10.0 , 0.0 ) , "greater than 0" , id = "width-zero" ),
305+ pytest .param (( 10.0 , - 1.0 ) , "greater than 0" , id = "width-negative" ),
306306 ],
307307)
308308def test_blank_pdf_custom_dimensions_validation (
309309 monkeypatch : pytest .MonkeyPatch ,
310- custom_height : float ,
311- custom_width : float ,
310+ page_size : tuple [float , float ],
312311 match : str ,
313312) -> None :
314313 monkeypatch .delenv ("PDFREST_API_KEY" , raising = False )
@@ -319,27 +318,24 @@ def test_blank_pdf_custom_dimensions_validation(
319318 pytest .raises (ValidationError , match = match ),
320319 ):
321320 client .blank_pdf (
322- page_size = "custom" ,
321+ page_size = page_size ,
323322 page_count = 1 ,
324- custom_height = custom_height ,
325- custom_width = custom_width ,
326323 )
327324
328325
329326@pytest .mark .asyncio
330327@pytest .mark .parametrize (
331- ("custom_height" , "custom_width " , "match" ),
328+ ("page_size " , "match" ),
332329 [
333- pytest .param (0.0 , 10.0 , "greater than 0" , id = "height-zero" ),
334- pytest .param (- 1.0 , 10.0 , "greater than 0" , id = "height-negative" ),
335- pytest .param (10.0 , 0.0 , "greater than 0" , id = "width-zero" ),
336- pytest .param (10.0 , - 1.0 , "greater than 0" , id = "width-negative" ),
330+ pytest .param (( 0.0 , 10.0 ) , "greater than 0" , id = "height-zero" ),
331+ pytest .param (( - 1.0 , 10.0 ) , "greater than 0" , id = "height-negative" ),
332+ pytest .param (( 10.0 , 0.0 ) , "greater than 0" , id = "width-zero" ),
333+ pytest .param (( 10.0 , - 1.0 ) , "greater than 0" , id = "width-negative" ),
337334 ],
338335)
339336async def test_async_blank_pdf_custom_dimensions_validation (
340337 monkeypatch : pytest .MonkeyPatch ,
341- custom_height : float ,
342- custom_width : float ,
338+ page_size : tuple [float , float ],
343339 match : str ,
344340) -> None :
345341 monkeypatch .delenv ("PDFREST_API_KEY" , raising = False )
@@ -348,10 +344,8 @@ async def test_async_blank_pdf_custom_dimensions_validation(
348344 async with AsyncPdfRestClient (api_key = ASYNC_API_KEY , transport = transport ) as client :
349345 with pytest .raises (ValidationError , match = match ):
350346 await client .blank_pdf (
351- page_size = "custom" ,
347+ page_size = page_size ,
352348 page_count = 1 ,
353- custom_height = custom_height ,
354- custom_width = custom_width ,
355349 )
356350
357351
@@ -458,10 +452,8 @@ def handler(request: httpx.Request) -> httpx.Response:
458452 transport = httpx .MockTransport (handler )
459453 with PdfRestClient (api_key = VALID_API_KEY , transport = transport ) as client :
460454 response = client .blank_pdf (
461- page_size = "custom" ,
455+ page_size = ( 792 , 612 ) ,
462456 page_count = 3 ,
463- custom_height = 792 ,
464- custom_width = 612 ,
465457 output = "custom" ,
466458 extra_query = {"trace" : "true" },
467459 extra_headers = {"X-Debug" : "sync" },
@@ -581,10 +573,8 @@ def handler(request: httpx.Request) -> httpx.Response:
581573 transport = httpx .MockTransport (handler )
582574 async with AsyncPdfRestClient (api_key = ASYNC_API_KEY , transport = transport ) as client :
583575 response = await client .blank_pdf (
584- page_size = "custom" ,
576+ page_size = ( 100 , 50 ) ,
585577 page_count = 1 ,
586- custom_height = 100 ,
587- custom_width = 50 ,
588578 extra_query = {"trace" : "async" },
589579 extra_headers = {"X-Debug" : "async" },
590580 extra_body = {"debug" : "yes" },
@@ -615,33 +605,18 @@ def test_blank_pdf_validation(monkeypatch: pytest.MonkeyPatch) -> None:
615605
616606 with (
617607 PdfRestClient (api_key = VALID_API_KEY , transport = transport ) as client ,
618- pytest .raises (ValueError , match = "custom_height and custom_width are required " ),
608+ pytest .raises (ValueError , match = "Custom page sizes must contain exactly two " ),
619609 ):
620- client .blank_pdf (page_size = "custom" , page_count = 1 , custom_height = 50 )
621-
622- with (
623- PdfRestClient (api_key = VALID_API_KEY , transport = transport ) as client ,
624- pytest .raises (
625- ValueError , match = "custom_height and custom_width can only be provided"
626- ),
627- ):
628- client .blank_pdf (
629- page_size = "A3" ,
630- page_count = 1 ,
631- page_orientation = "portrait" ,
632- custom_width = 10 ,
633- )
610+ client .blank_pdf (page_size = (50 ,), page_count = 1 )
634611
635612 with (
636613 PdfRestClient (api_key = VALID_API_KEY , transport = transport ) as client ,
637614 pytest .raises (ValueError , match = "page_orientation must be omitted" ),
638615 ):
639616 client .blank_pdf (
640- page_size = "custom" ,
617+ page_size = ( 10 , 10 ) ,
641618 page_count = 1 ,
642619 page_orientation = "portrait" ,
643- custom_width = 10 ,
644- custom_height = 10 ,
645620 )
646621
647622 with (
0 commit comments