Skip to content

Commit 840dd88

Browse files
tests: Add endpoint-owned branch coverage for async client methods
- Add non-live sync and async coverage for optional payload branches (output/output_prefix/pages/page_groups) in each endpoint's home test module - Add async preview_redactions unit coverage in test_pdf_redaction_preview - Keep coverage aligned with endpoint ownership instead of a shared cross-endpoint helper module - Update TESTING_GUIDELINES.md to require endpoint-home tests and optional-branch coverage in both sync and async customization/success cases Assisted-by: Codex
1 parent ea9b9d1 commit 840dd88

21 files changed

Lines changed: 111 additions & 4 deletions

TESTING_GUIDELINES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ iteration required.
1919
asserting method/path/headers/body). Optional payload branches (for example,
2020
`pages`, `output`, `rgb_color`, and output-prefix fields) require explicit
2121
tests so serialization differences are caught early.
22+
- **Keep endpoint tests in their home files.** When adding or restoring coverage
23+
for an endpoint, place the test in that endpoint's existing test module (for
24+
example, `tests/test_convert_to_excel.py`), not in a generic cross-endpoint
25+
coverage file.
2226
- **Check client coverage regularly.** Run `uvx nox -s class-coverage` to
2327
enforce minimum function-level coverage for `PdfRestClient` and
2428
`AsyncPdfRestClient`.
@@ -95,6 +99,10 @@ iteration required.
9599
or `timeout`, add explicit tests (sync + async) proving those options
96100
propagate. Capture `request.extensions["timeout"]` and assert every component
97101
equals `pytest.approx(expected)`.
102+
- For both sync and async endpoint helpers, ensure request-customization or
103+
success tests also exercise endpoint-specific optional payload branches (for
104+
example `output`, `output_prefix`, `pages`, `page_groups`, redaction payloads)
105+
so non-live class-function coverage does not depend on live suites.
98106

99107
### Validation & Payload Modeling
100108

tests/test_blank_pdf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ def handler(request: httpx.Request) -> httpx.Response:
668668
assert payload["custom_height"] == 100
669669
assert payload["custom_width"] == 50
670670
assert "page_orientation" not in payload
671+
assert payload["output"] == "async-custom"
671672
assert payload["debug"] == "yes"
672673
return httpx.Response(
673674
200,
@@ -695,6 +696,7 @@ def handler(request: httpx.Request) -> httpx.Response:
695696
response = await client.blank_pdf(
696697
page_size={"custom_height": 100, "custom_width": 50},
697698
page_count=1,
699+
output="async-custom",
698700
extra_query={"trace": "async"},
699701
extra_headers={"X-Debug": "async"},
700702
extra_body={"debug": "yes"},

tests/test_convert_colors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def handler(request: httpx.Request) -> httpx.Response:
277277
assert payload["color_profile"] == "custom"
278278
assert payload["profile_id"] == str(profile_file.id)
279279
assert payload["preserve_black"] == "false"
280+
assert payload["output"] == "async-custom"
280281
return httpx.Response(
281282
200,
282283
json={
@@ -304,6 +305,7 @@ def handler(request: httpx.Request) -> httpx.Response:
304305
response = await client.convert_colors(
305306
input_file,
306307
color_profile=profile_file,
308+
output="async-custom",
307309
extra_query={"trace": "async"},
308310
extra_headers={"X-Debug": "async"},
309311
extra_body={"debug": "yes"},

tests/test_convert_to_excel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def handler(request: httpx.Request) -> httpx.Response:
204204
payload = json.loads(request.content.decode("utf-8"))
205205
assert payload["debug"] == "yes"
206206
assert payload["id"] == str(input_file.id)
207+
assert payload["output"] == "async-custom"
207208
return httpx.Response(
208209
200,
209210
json={
@@ -230,6 +231,7 @@ def handler(request: httpx.Request) -> httpx.Response:
230231
async with AsyncPdfRestClient(api_key=ASYNC_API_KEY, transport=transport) as client:
231232
response = await client.convert_to_excel(
232233
input_file,
234+
output="async-custom",
233235
extra_query={"trace": "async"},
234236
extra_headers={"X-Debug": "async"},
235237
extra_body={"debug": "yes"},

tests/test_convert_to_pdfa.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def handler(request: httpx.Request) -> httpx.Response:
227227
payload = json.loads(request.content.decode("utf-8"))
228228
assert payload["output_type"] == "PDF/A-2u"
229229
assert payload["id"] == str(input_file.id)
230+
assert payload["output"] == "async-custom"
230231
assert payload["extra"] == {"note": "async"}
231232
assert payload["rasterize_if_errors_encountered"] == "off"
232233
return httpx.Response(
@@ -251,6 +252,7 @@ def handler(request: httpx.Request) -> httpx.Response:
251252
response = await client.convert_to_pdfa(
252253
input_file,
253254
output_type="PDF/A-2u",
255+
output="async-custom",
254256
rasterize_if_errors_encountered="off",
255257
extra_query={"trace": "async"},
256258
extra_headers={"X-Debug": "async"},

tests/test_convert_to_pdfx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def handler(request: httpx.Request) -> httpx.Response:
214214
payload = json.loads(request.content.decode("utf-8"))
215215
assert payload["output_type"] == "PDF/X-6"
216216
assert payload["id"] == str(input_file.id)
217+
assert payload["output"] == "async-custom"
217218
assert payload["extra"] == {"note": "async"}
218219
return httpx.Response(
219220
200,
@@ -237,6 +238,7 @@ def handler(request: httpx.Request) -> httpx.Response:
237238
response = await client.convert_to_pdfx(
238239
input_file,
239240
output_type="PDF/X-6",
241+
output="async-custom",
240242
extra_query={"trace": "async"},
241243
extra_headers={"X-Debug": "async"},
242244
extra_body={"extra": {"note": "async"}},

tests/test_convert_to_powerpoint.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def handler(request: httpx.Request) -> httpx.Response:
204204
payload = json.loads(request.content.decode("utf-8"))
205205
assert payload["debug"] == "yes"
206206
assert payload["id"] == str(input_file.id)
207+
assert payload["output"] == "async-custom"
207208
return httpx.Response(
208209
200,
209210
json={
@@ -230,6 +231,7 @@ def handler(request: httpx.Request) -> httpx.Response:
230231
async with AsyncPdfRestClient(api_key=ASYNC_API_KEY, transport=transport) as client:
231232
response = await client.convert_to_powerpoint(
232233
input_file,
234+
output="async-custom",
233235
extra_query={"trace": "async"},
234236
extra_headers={"X-Debug": "async"},
235237
extra_body={"debug": "yes"},

tests/test_convert_to_word.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def handler(request: httpx.Request) -> httpx.Response:
204204
payload = json.loads(request.content.decode("utf-8"))
205205
assert payload["debug"] == "yes"
206206
assert payload["id"] == str(input_file.id)
207+
assert payload["output"] == "async-custom"
207208
return httpx.Response(
208209
200,
209210
json={
@@ -230,6 +231,7 @@ def handler(request: httpx.Request) -> httpx.Response:
230231
async with AsyncPdfRestClient(api_key=ASYNC_API_KEY, transport=transport) as client:
231232
response = await client.convert_to_word(
232233
input_file,
234+
output="async-custom",
233235
extra_query={"trace": "async"},
234236
extra_headers={"X-Debug": "async"},
235237
extra_body={"debug": "yes"},

tests/test_convert_xfa_to_acroforms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def handler(request: httpx.Request) -> httpx.Response:
198198
payload = json.loads(request.content.decode("utf-8"))
199199
assert payload["debug"] == "yes"
200200
assert payload["id"] == str(input_file.id)
201+
assert payload["output"] == "async-custom"
201202
return httpx.Response(
202203
200,
203204
json={
@@ -224,6 +225,7 @@ def handler(request: httpx.Request) -> httpx.Response:
224225
async with AsyncPdfRestClient(api_key=ASYNC_API_KEY, transport=transport) as client:
225226
response = await client.convert_xfa_to_acroforms(
226227
input_file,
228+
output="async-custom",
227229
extra_query={"trace": "async"},
228230
extra_headers={"X-Debug": "async"},
229231
extra_body={"debug": "yes"},

tests/test_export_form_data.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def handler(request: httpx.Request) -> httpx.Response:
262262
payload = json.loads(request.content.decode("utf-8"))
263263
assert payload["id"] == str(input_file.id)
264264
assert payload["data_format"] == "xml"
265+
assert payload["output"] == "async-custom"
265266
assert payload["note"] == "details"
266267
return httpx.Response(
267268
200,
@@ -290,6 +291,7 @@ def handler(request: httpx.Request) -> httpx.Response:
290291
response = await client.export_form_data(
291292
input_file,
292293
data_format="xml",
294+
output="async-custom",
293295
extra_query={"trace": "async"},
294296
extra_headers={"X-Debug": "async"},
295297
extra_body={"note": "details"},

0 commit comments

Comments
 (0)