Repository navigation
Add test_serve.py covering the prediction server (part of #7) - #12
Merged
Merged
Conversation
Tests the runtime/serve.py request handler over a live socket on an ephemeral port: /health, /predict, /predict_batch, plus the 400 (missing field), 500 (embedding-dim mismatch) and 404 (unknown path) error paths. Stdlib-only, clean shutdown in fixture teardown.
adrida
approved these changes
Jun 8, 2026
adrida
left a comment
Owner
There was a problem hiding this comment.
Reviewed against serve.py: every assertion matches the real handler, /health, /predict (200, 400 on missing field, 500 on dim mismatch), /predict_batch (200, 400), and the GET/POST 404 paths. Good call binding an ephemeral port in a daemon thread with clean shutdown rather than calling serve(). Module-scoped fixtures, no global leak. CI green across 3.9 to 3.13. Thank you.
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.
First item from #7 (the biggest untested surface, and the part people actually deploy).
Tests
runtime/serve.pyover a live socket on an ephemeral port (127.0.0.1:0), started in a background thread and shut down cleanly in fixture teardown so nothing leaks between test files. Stdlib only, no new dependencies.Coverage:
GET /healthshape (method, coverage, label count)POST /predictrouting decision, and the400(missing field) and500(embedding-dim mismatch) pathsPOST /predict_batchhappy path and400on missing field404on unknown GET and POST pathsPart of #7.