Skip to content

Commit 277cfad

Browse files
AGENTS.md: Update testing guidelines with live test requirements
- Added requirement for live pytest modules under `tests/live/` for all new endpoints and services. - Emphasized parameterization, coverage of accepted literals, and at least one invalid input test. - Clarified guidelines for reviewers to block changes without live tests or an explicit follow-up plan. - Enhanced recommendations for pytest parameterization to improve test case clarity and reduce duplication. Assisted-by: Codex
1 parent 014162e commit 277cfad

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,48 @@
111111

112112
## Testing Guidelines
113113

114+
- **Live Test Requirement (Do Not Skip):** Every new endpoint or service must
115+
ship with a matching live pytest module under `tests/live/` before the work is
116+
considered complete. Mirror the naming/structure used by the graphic
117+
conversion suites: one module per endpoint, parameterized success cases that
118+
enumerate all accepted literals, at least one invalid input that hits the
119+
server, and coverage for any request options surfaced on the client. If an
120+
endpoint cannot be exercised live, call that out explicitly in the PR
121+
description with the reason and the follow-up plan; otherwise reviewers should
122+
block the change. Treat this as a release gate on par with unit tests.
123+
114124
- Write pytest tests: files named `test_*.py`, test functions `test_*`, fixtures
115125
in `conftest.py` where shared.
126+
116127
- Ensure high-value coverage of public functions and edge cases; document intent
117128
in test docstrings when non-obvious.
129+
118130
- Use `uvx nox -s tests` to exercise the full interpreter matrix locally when
119131
validating compatibility.
132+
120133
- When writing live tests for URL uploads, first create the remote resources via
121134
`create_from_paths`, then reuse the returned URLs in `create_from_urls` to
122135
avoid relying on third-party availability.
136+
123137
- For parameterized tests prefer `pytest.param(..., id="short-label")` so test
124138
IDs stay readable; make assertions for every relevant response attribute (name
125139
prefix, MIME type, size, URLs, warnings).
140+
126141
- Avoid manual loops over test parameters; prefer `@pytest.mark.parametrize`
127142
with explicit `id=` values so each combination is visible and reproducible.
143+
128144
- Always couple `pytest.raises` with an explicit `match=` regex that reflects
129145
the intended validation error wording—mirror the human-readable text rather
130146
than relying on default exception formatting.
147+
131148
- Mirror PNG’s request/response scenarios for each graphic conversion endpoint:
132149
maintain per-endpoint test modules (`test_convert_to_png.py`,
133150
`test_convert_to_bmp.py`, etc.) covering success, parameter customization,
134151
validation errors, multi-file guards, and async flows. Keep shared payload
135152
validation (output prefix and page-range cases) in a dedicated suite (e.g.,
136153
`tests/test_graphic_payload_validation.py`) that exercises every payload
137154
model.
155+
138156
- When introducing additional pdfRest endpoints, follow the same pattern used
139157
for graphic conversions: encapsulate shared request validation in a typed
140158
payload model, expose fully named client methods, and create a dedicated test
@@ -143,15 +161,20 @@
143161
checks (e.g., common field requirements, payload serialization) in shared
144162
helper tests so new services inherit consistent coverage with minimal
145163
duplication.
164+
146165
- Prefer `pytest.mark.parametrize` (with `pytest.param(..., id="...")`) over
147-
explicit loops inside tests; nest parametrization for multi-dimensional
148-
coverage so each case appears as an individual test item.
166+
explicit loops or copy/paste blocks—if only the input value or expected error
167+
changes, parameterize it so failures point to the exact case and reviewers
168+
don’t have to diff almost-identical code. Nest parametrization for
169+
multi-dimensional coverage so each combination appears as its own test item.
170+
149171
- Live tests should verify that literal enumerations match pdfRest’s accepted
150172
values. Exercise format-specific options (e.g., each image format’s
151173
`color_model`) individually, and run smoothing enumerations through every
152174
enabled endpoint to confirm consistent server behaviour. Include “wildly”
153175
invalid values (e.g., bogus literals or mixed lists) alongside boundary
154176
failures so the server-side error messaging is exercised.
177+
155178
- Provide live integration tests under `tests/live/` (with an `__init__.py` so
156179
pytest discovers the package) that introspect payload models to enumerate
157180
valid/invalid literal values and numeric boundaries. These tests should vary a
@@ -162,11 +185,13 @@
162185
exception surfaced by the client). When test fixtures produce deterministic
163186
results (e.g., `tests/resources/report.pdf`), assert the concrete values
164187
returned by pdfRest rather than only checking for presence or type.
188+
165189
- Use `tests/resources/20-pages.pdf` for high-page-count scenarios such as split
166190
and merge endpoints so boundary coverage (multi-output splits, staggered page
167191
selections) remains reproducible. Parameterize live split/merge tests to cover
168192
multiple page-group patterns, and pair each success case with an invalid input
169193
that reaches the server by overriding the JSON body via `extra_body`.
194+
170195
- Developers can load a pdfRest API key from `.env` during ad-hoc exploration.
171196
The repo includes `python-dotenv`; call `load_dotenv()` (optionally pointing
172197
to `.env`) in temporary scripts to drive the in-flight client against live

0 commit comments

Comments
 (0)