MLOps + Cloud Deploy (AWS-First)
Back to M1 — FastAPI Serving + Smoke Tests

Schema Validation + Smoke Tests

Write 5 smoke tests incl bad-input cases.

3 minutesReading
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Write 5 smoke tests including bad-input cases for the FastAPI serving lesson.

1. Contract first

/health returns 200 + version. /predict validates input via pydantic schemas (types, ranges, required fields) and returns predictions + model version. Unknown fields are rejected or explicitly ignored — pick one and log it.

2. The 5 smoke tests

  1. /health 200 with version string. 2. Valid /predict returns 200 with the right schema. 3. Missing required field returns 422. 4. Out-of-range value returns 422. 5. Wrong type (string for float) returns 422. Each test asserts status + a key field, never the full body.

3. Extend the backend pattern

Mirror backend/app/main.py /health shape so the serving code reads like the codebase it deploys into. Smoke file lives at tests/test_smoke.py and runs inside the Docker smoke command from m0.

Loading progress...