Skip to content

Commit 488e6a6

Browse files
noxfile, docs: Add detailed coverage report generation and documentation updates
- Updated `noxfile.py` to include coverage reports in HTML, XML, and Markdown, stored under `coverage/py<version>/`. - Extended `TESTING_GUIDELINES.md` and `AGENTS.md` to document new coverage report formats and locations. - Reinforced maintaining high client coverage for key methods and ensuring serialization of optional payload branches is tested. Assisted-by: Codex
1 parent f6bb554 commit 488e6a6

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,4 @@ $RECYCLE.BIN/
453453
*.speedscope.json
454454

455455
!pyrightconfig.json
456+
/coverage/

AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
- `nox` executes pytest sessions with built-in parallelism; when invoking pytest
2929
directly use `pytest -n 8 --maxschedchunk 2` to mirror the parallel test
3030
scheduling and keep runtimes predictable.
31+
- Coverage reports (XML/Markdown/HTML) are produced by the nox `tests` session
32+
and stored under `coverage/py<version>/` (for example,
33+
`coverage/py3.12/coverage.xml`, `coverage/py3.12/coverage.md`,
34+
`coverage/py3.12/html/`).
3135

3236
## Coding Style & Naming Conventions
3337

@@ -138,6 +142,13 @@
138142
description with the reason and the follow-up plan; otherwise reviewers should
139143
block the change. Treat this as a release gate on par with unit tests.
140144

145+
- **Client coverage criteria:** `PdfRestClient` and `AsyncPdfRestClient` are
146+
customer-facing entry points and must retain high coverage. Every public
147+
client method must have at least one unit test that exercises the REST call
148+
path (MockTransport + request assertions), with distinct sync and async tests.
149+
Optional payload branches (`pages`, `output`, `rgb_color`, etc.) need explicit
150+
coverage so serialization regressions are caught.
151+
141152
- Write pytest tests: files named `test_*.py`, test functions `test_*`, fixtures
142153
in `conftest.py` where shared.
143154

TESTING_GUIDELINES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,23 @@ iteration required.
1313
request customization, validation failures, file helpers, and live calls. Do
1414
not hide the transport behind a parameter; the test name itself should reveal
1515
which client is under test.
16+
- **Maintain high client coverage.** `PdfRestClient` and `AsyncPdfRestClient`
17+
are the primary customer-facing entry points. Every public client method must
18+
have at least one unit test that exercises the REST call path (MockTransport
19+
asserting method/path/headers/body). Optional payload branches (for example,
20+
`pages`, `output`, `rgb_color`, and output-prefix fields) require explicit
21+
tests so serialization differences are caught early.
1622
- **Check parity regularly.** Run `scripts/check_test_parity.sh` (defaults to
1723
`upstream/main..HEAD`) to spot missing sync/async counterparts, keeping
1824
parameterized test IDs aligned between transports.
1925
- **Exercise both sides of the contract.** Hermetic tests (via
2026
`httpx.MockTransport`) validate serialization and local validation. Live
2127
suites prove the server behaves the same way, including invalid literal
2228
handling.
29+
- **Know where coverage lands.** The nox `tests` session writes coverage reports
30+
to `coverage/py<version>/` (XML, Markdown, and HTML). Example:
31+
`coverage/py3.12/coverage.xml`, `coverage/py3.12/coverage.md`,
32+
`coverage/py3.12/html/`.
2333
- **Reset global state per test.** Use
2434
`monkeypatch.delenv("PDFREST_API_KEY", raising=False)` (or `setenv`) so
2535
clients never inherit accidental API keys. Patch `importlib.metadata.version`

noxfile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,18 @@ def tests(session: nox.Session) -> None:
189189
f"--python={session.virtualenv.location}",
190190
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
191191
)
192+
coverage_dir = PROJECT_ROOT / "coverage" / f"py{session.python}"
193+
coverage_dir.mkdir(parents=True, exist_ok=True)
194+
htmlcov_dir = coverage_dir / "html"
195+
xml_report = coverage_dir / "coverage.xml"
196+
md_report = coverage_dir / "coverage.md"
192197
_ = session.run(
193198
"pytest",
194199
"--cov=pdfrest",
195200
"--cov-report=term-missing",
201+
f"--cov-report=html:{htmlcov_dir}",
202+
f"--cov-report=xml:{xml_report}",
203+
f"--cov-report=markdown:{md_report}",
196204
*pytest_args,
197205
)
198206

0 commit comments

Comments
 (0)