Repository navigation
Add behavior tests for the health and hello endpoints - #1
Merged
Merged
Conversation
Line coverage was already 100%, but most behavior had no assertions. The new tests cover: - response bodies, the 64-character limit (counted in characters, not bytes) and unicode/emoji/special-character names - 422 error details, unknown and repeated query parameters - 404, 405 with the Allow header, and the trailing-slash redirect - the logging middleware: format, no query string, /healthz skipped, timing taken from perf_counter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What changes
Adds 31 tests to
tests/test_main.py(4 → 35). No changes toapp/, dependencies or CI.Line coverage of
app/main.pywas already 100%, but most behavior had no assertions. The new tests pin down:/healthz: response body is{"status": "ok"}./hello: valid names (parametrized: 1 and 64 characters, empty, accents, Japanese, emoji, special characters,<script>); the 64-character limit is counted in characters, not bytes; 422 details (loc,type == "string_too_long"); unknown query params are ignored; with a repeatedname, the last value wins./healthz/, 405 with anAllow: GETheader for other methods.caplog): one line per request in theGET /hello 200 <ms>msformat, no query string in the log, 4xx statuses logged,/healthznot logged, timing taken fromperf_counter.Why
Coverage alone didn't protect the API's contract: a change to the length limit, the error format or the logging middleware would still pass the old tests.
How to test
35 passed locally, 100% line coverage on
app/main.py;ruff checkandruff format --checkare clean.🤖 Generated with Claude Code