|
85 | 85 | instances (optionally sequences) rather than raw IDs or strings; use the |
86 | 86 | `files` client helpers to resolve file IDs before invoking conversion or |
87 | 87 | metadata routes. |
| 88 | +- For document splitting and merging, expose rich Python types on the client |
| 89 | + surface (`PdfPageSelection`, `PdfMergeInput`) and validate them through the |
| 90 | + `PdfSplitPayload`/`PdfMergePayload` models. Normalize per-output page groups |
| 91 | + with the shared page-range validator, default merge items without explicit |
| 92 | + ranges to `"1-last"`, and serialize merge requests into the parallel `id`, |
| 93 | + `pages`, and `type` arrays that pdfRest expects (always emitting `"id"` for |
| 94 | + `type[]`). Split/merge payloads accept descending ranges (e.g., `"9-2"`) and |
| 95 | + the `"even"`/`"odd"` selectors; graphic conversions remain limited to positive |
| 96 | + numbers, `"last"`, and ascending ranges to match the live API behaviour. |
| 97 | +- Favor declarative Pydantic validation over bespoke “normalize” helpers: define |
| 98 | + nested models, unions, and annotated tuples that parse complex strings into |
| 99 | + typed structures (as with the split/merge page-range tuples) and let small |
| 100 | + validators enforce the constraints (`BeforeValidator` for parsing, |
| 101 | + `AfterValidator` for relational checks). Reserve standalone normalization |
| 102 | + functions for behaviour that cannot live on the schema—simpler models produce |
| 103 | + clearer errors and are easier for new contributors to understand. |
88 | 104 | - When adding new services, provide per-endpoint test modules mirroring PNG’s |
89 | 105 | coverage: parameterized successes for every allowed literal value, request |
90 | 106 | customization (sync + async), validation failures, and multi-file guards. Add |
|
146 | 162 | exception surfaced by the client). When test fixtures produce deterministic |
147 | 163 | results (e.g., `tests/resources/report.pdf`), assert the concrete values |
148 | 164 | returned by pdfRest rather than only checking for presence or type. |
| 165 | +- Use `tests/resources/20-pages.pdf` for high-page-count scenarios such as split |
| 166 | + and merge endpoints so boundary coverage (multi-output splits, staggered page |
| 167 | + selections) remains reproducible. Parameterize live split/merge tests to cover |
| 168 | + multiple page-group patterns, and pair each success case with an invalid input |
| 169 | + that reaches the server by overriding the JSON body via `extra_body`. |
149 | 170 | - Developers can load a pdfRest API key from `.env` during ad-hoc exploration. |
150 | 171 | The repo includes `python-dotenv`; call `load_dotenv()` (optionally pointing |
151 | 172 | to `.env`) in temporary scripts to drive the in-flight client against live |
|
0 commit comments