Skip to content

Commit 72b2c10

Browse files
Update Agents.md for split/merge and better tests
- Enhanced `AGENTS.md` with rich type usage, updated live tests, and reproducible fixtures. Assisted-by: Codex
1 parent 7cb6685 commit 72b2c10

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@
8585
instances (optionally sequences) rather than raw IDs or strings; use the
8686
`files` client helpers to resolve file IDs before invoking conversion or
8787
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.
88104
- When adding new services, provide per-endpoint test modules mirroring PNG’s
89105
coverage: parameterized successes for every allowed literal value, request
90106
customization (sync + async), validation failures, and multi-file guards. Add
@@ -146,6 +162,11 @@
146162
exception surfaced by the client). When test fixtures produce deterministic
147163
results (e.g., `tests/resources/report.pdf`), assert the concrete values
148164
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`.
149170
- Developers can load a pdfRest API key from `.env` during ad-hoc exploration.
150171
The repo includes `python-dotenv`; call `load_dotenv()` (optionally pointing
151172
to `.env`) in temporary scripts to drive the in-flight client against live

0 commit comments

Comments
 (0)