Test-Driven Development with Python, Flask, and Docker

Learn how to build, test, and deploy a microservice powered by Python, Flask, and Docker!

"Code without tests is broken by design." - Jacob Kaplan-Moss

Learning Objectives

By the end of this course, you will be able to:

Develop a RESTful API with Python, Flask, and Flask-RESTX Practice Test-Driven Development Test a Flask app with Pytest Containerize Flask and Postgres inside a Docker container Run unit and integration tests with code coverage inside a Docker container Check your code for any code quality issues via a linter Configure GitLab CI for continuous integration and deployment Speed up a Docker-based CI build with Docker Cache Deploy Flask, Gunicorn, and Postgres to Heroku with Docker Parameterize test functions and mock functionality in tests with Pytest Run tests in parallel with pytest-xdist Configure Flask-Admin with SQLAlchemy models Document a RESTful API with Swagger/OpenAPI

Tools and Technologies

Python Flask Docker Postgres Pytest Flask-RESTX Flask-SQLAlchemy Gunicorn Coverage.py flake8 Black isort HTTPie Flask-Admin GitLab Heroku Swagger/OpenAPI

Prerequisites

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:

Demo

Info

Current version: 3.0.0

Last updated: March 26th, 2020

Author: Michael Herman

What will you learn?

Part 1

In this first part, you'll learn how to develop a RESTful API with Python, the Flask web framework, Flask-RESTX, and Postgres. You'll containerize Flask and Postgres to run inside Docker containers and configure Pytest in order to practice Test-Driven Development (TDD).

Part 2

In the second part, you'll start by deploying Flask, Gunicorn, and Postgres to Heroku with Docker. You'll then continue building the out the RESTful API as you write unit and integration tests. Finally, we'll look at how to document the API with Swagger.