@@ -40,6 +40,14 @@ def test_convert_to_markdown_payload_invalid_page_range() -> None:
4040 )
4141
4242
43+ def test_convert_to_markdown_payload_invalid_page_break_comments () -> None :
44+ file_repr = make_pdf_file (PdfRestFileID .generate (1 ))
45+ with pytest .raises (ValidationError , match = "Input should be 'on' or 'off'" ):
46+ ConvertToMarkdownPayload .model_validate (
47+ {"files" : [file_repr ], "page_break_comments" : "maybe" }
48+ )
49+
50+
4351def test_convert_to_markdown_json_success (monkeypatch : pytest .MonkeyPatch ) -> None :
4452 monkeypatch .delenv ("PDFREST_API_KEY" , raising = False )
4553 input_file = make_pdf_file (PdfRestFileID .generate (1 ))
@@ -50,6 +58,7 @@ def test_convert_to_markdown_json_success(monkeypatch: pytest.MonkeyPatch) -> No
5058 "output" : "md" ,
5159 "output_type" : "json" ,
5260 "output_format" : "markdown" ,
61+ "page_break_comments" : "on" ,
5362 }
5463 ).model_dump (mode = "json" , by_alias = True , exclude_none = True , exclude_unset = True )
5564
@@ -79,6 +88,7 @@ def handler(request: httpx.Request) -> httpx.Response:
7988 output = "md" ,
8089 output_type = "json" ,
8190 output_format = "markdown" ,
91+ page_break_comments = "on" ,
8292 )
8393
8494 assert seen == {"post" : 1 }
@@ -95,7 +105,12 @@ def test_convert_to_markdown_request_customization(
95105 monkeypatch .delenv ("PDFREST_API_KEY" , raising = False )
96106 input_file = make_pdf_file (PdfRestFileID .generate (1 ))
97107 payload_dump = ConvertToMarkdownPayload .model_validate (
98- {"files" : [input_file ], "output_type" : "file" , "output_format" : "markdown" }
108+ {
109+ "files" : [input_file ],
110+ "output_type" : "file" ,
111+ "output_format" : "markdown" ,
112+ "page_break_comments" : "off" ,
113+ }
99114 ).model_dump (mode = "json" , by_alias = True , exclude_none = True , exclude_unset = True )
100115 output_id = str (PdfRestFileID .generate ())
101116 captured_timeout : dict [str , float | dict [str , float ] | None ] = {}
@@ -129,6 +144,7 @@ def handler(request: httpx.Request) -> httpx.Response:
129144 extra_headers = {"X-Debug" : "sync" },
130145 extra_body = {"debug" : True },
131146 timeout = 0.4 ,
147+ page_break_comments = "off" ,
132148 )
133149
134150 assert isinstance (response , ConvertToMarkdownResponse )
@@ -151,7 +167,7 @@ async def test_async_convert_to_markdown_success(
151167 monkeypatch .delenv ("PDFREST_API_KEY" , raising = False )
152168 input_file = make_pdf_file (PdfRestFileID .generate (2 ))
153169 payload_dump = ConvertToMarkdownPayload .model_validate (
154- {"files" : [input_file ], "output_type" : "json" }
170+ {"files" : [input_file ], "output_type" : "json" , "page_break_comments" : "off" }
155171 ).model_dump (mode = "json" , by_alias = True , exclude_none = True , exclude_unset = True )
156172
157173 seen : dict [str , int ] = {"post" : 0 }
@@ -174,7 +190,9 @@ def handler(request: httpx.Request) -> httpx.Response:
174190
175191 transport = httpx .MockTransport (handler )
176192 async with AsyncPdfRestClient (api_key = ASYNC_API_KEY , transport = transport ) as client :
177- response = await client .convert_to_markdown (input_file , output_type = "json" )
193+ response = await client .convert_to_markdown (
194+ input_file , output_type = "json" , page_break_comments = "off"
195+ )
178196
179197 assert seen == {"post" : 1 }
180198 assert isinstance (response , ConvertToMarkdownResponse )
0 commit comments