Interview Prep/Python for DevOps/Testing, CI/CD, packaging & services

You want contract tests for an internal REST API your scripts depend on. What do you do?

AdvancedScenarioTesting, CI/CD, packaging & services
Answer

Situation read → Your scripts break when the API changes shape.

What I'd do →

  1. Validate responses against the API's OpenAPI schema in a scheduled integration test (jsonschema or schemathesis).
  2. Model responses with pydantic in the client, so shape changes fail loudly at the boundary.
  3. Record real responses as fixtures (sanitized) for unit tests with responses.
  4. Agree on versioning with the API team; consumer-driven contracts (Pact) if the relationship is critical.

Why → Boundary validation turns silent data bugs into clear errors.

Interview tip → Mention pydantic models as runtime contracts.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, CI/CD, packaging & services