Skip to course content
Free FastAPI backend course

FastAPI for AI Backend Development

Module 09 Activity

Scenario

Build the suite that runs on every save.

What you build

An offline test suite covering the contract, with fixtures that isolate and the expensive dependency overridden.

Steps

  1. Write contract tests with TestClient covering the success path and every error status you declared.
  2. Write fixtures that reset shared state, and prove two tests do not interact.
  3. Override the expensive dependency and confirm the real one is never built. Clear the override afterwards.
  4. Replace exact-response assertions with contract assertions, including one that no unexpected field is present.
  5. Split the suite into offline and networked groups and report the count and wall clock of each.
  6. Confirm the offline group passes with no key and runs in seconds.

Evidence to hand in

Review checklist