Skip to content

Service as Consumer and Provider

This example demonstrates a common microservice pattern where one service plays both roles in contract testing:

  • Provider to a frontend client (frontend-web → user-service)
  • Consumer of an upstream auth service (user-service → auth-service)

Overview

Use the links above to view detailed documentation within each file.

What This Example Demonstrates

  • One service owning two separate contracts in opposite directions
  • Consumer tests for each dependency boundary
  • Provider verification with state handlers that model upstream auth-service behaviour without needing it to run
  • A Protocol-based seam that allows the real FastAPI application to run during verification while the upstream dependency is replaced in-process

Running the Example

uv run --group test pytest