Skip to content

Add test_serve.py covering the prediction server (part of #7) - #12

Merged
adrida merged 1 commit into
adrida:mainfrom
ilanoh:test/serve-endpoints
Jun 8, 2026
Merged

adrida merged 1 commit into
adrida:mainfrom
ilanoh:test/serve-endpoints

Conversation

@ilanoh

@ilanoh ilanoh commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

First item from #7 (the biggest untested surface, and the part people actually deploy).

Tests runtime/serve.py over 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 /health shape (method, coverage, label count)
  • POST /predict routing decision, and the 400 (missing field) and 500 (embedding-dim mismatch) paths
  • POST /predict_batch happy path and 400 on missing field
  • 404 on unknown GET and POST paths

Part of #7.

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 adrida left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@adrida
adrida merged commit d1f0996 into adrida:main Jun 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants