Test-Driven Development with FastAPI and Docker course (v1.2.2)
ref: https://testdriven.io/courses/tdd-fastapi/
Learn how to build, test, and deploy a text summarization microservice with Python, FastAPI, and Docker!
Author: Michael Herman (Real Python co-founder)
What do you need to know?
This is not a beginner course. It's designed for the advanced-beginner -- someone with at least six months of web development experience. Before beginning, you should have some familiarity with the following topics. Refer to these resources for more info:
Docker and Docker Compose:
- Get started with Docker
- Get started with Docker Compose
- Docker Best Practices for Python Developers FastAPI
- First Steps from the official FastAPI tutorial
What tools and technologies are used in this course?
№ | Core | Testing and Linting | Services |
---|---|---|---|
1 | Python | pytest | GitHub Actions |
2 | FastAPI | Coverage.py | GitHub Packages |
3 | Docker | Flake8 | Heroku |
4 | Postgres | Black | |
5 | Tortoise ORM | isort | |
6 | Uvicorn | HTTPie | |
7 | Gunicorn | ||
8 | Swagger/OpenAPI |
** and Python-Poetry in my case.
In this first part, you'll learn how to develop an async RESTful API with Python, FastAPI, and Postgres. You'll containerize FastAPI and Postgres to run inside Docker containers and configure pytest in order to practice Test-Driven Development (TDD).
- Develop an asynchronous RESTful API with Python and FastAPI
- Practice Test-Driven Development
- Test a FastAPI app with pytest
- Interact with a Postgres database asynchronously
- Containerize FastAPI and Postgres inside a Docker container
- Run unit and integration tests with code coverage
- Check your code for any code quality issues via a linter
In the second part, you'll start by deploying FastAPI, Gunicorn, Uvicorn, and Postgres to Heroku with Docker. You'll then continue to build out the RESTful API as you write unit and integration tests. Finally, we'll develop a text summarization service to produce article summaries from a given URL.
- Configure GitHub Actions for continuous integration and deployment
- Use GitHub Packages to store Docker Images
- Speed up a Docker-based CI build with Docker Cache
- Deploy FastAPI, Uvicorn, and Postgres to Heroku with Docker
- Parameterize test functions and mock functionality in tests with pytest
- Run tests in parallel with pytest-xdist
- Document a RESTful API with Swagger/OpenAPI
- Run a background process outside the request/response flow