Contract Testing in Python for a Data Science API
summary
Demo of using JSON Schema as a formal contract for a Python-backed REST microservice, showing concrete tests that validate request and response shape rather than brittle exact values. Shows tooling: generating schemas with quicktype, validating with jsonschema.validate in pytest, enumerating all validation errors to produce precise 4xx messages, and deploying a Flask service on Cloud Foundry. Promises examples, sample code, and CI-friendly patterns for swapping implementations and A/B testing.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:46API collaboration challenge
- 3:49RESTful API design
- 5:40API contracts matter
- 8:27Self-describing data formats
- 9:54Need for contract testing
- 12:23JSON Schema solution
- 13:05JSON Schema basics
- 16:17Generating JSON Schema
- 18:26JSON Schema validation
- 19:52Contract testing benefits
- 21:59Error messages with JSON Schema
- 22:41Recap
- 24:26Separation of concerns
- 25:55JSON Schema advantages
- 27:21Swagger integration
- 28:05Cloud Foundry deployment
related talks
33mHow to quickly and painlessly close an API regression from PyTest + JSON Schema
44mAPI Testing following the Test Pyramid
24mEffective API schemas testing
07m"Using schemas in your API Automation"
32mAn intro into API testing in Python
22mMicro Testing Pains
30mAPI Evolution With CRDs: Best Practices For Authoring & Fuzz Testing APIs
37mContract testing with examples or Contract First
