liveBook · Manning

Pytest-docker-tools

As explained in Data Pipelines with Apache Airflow, Second Edition

pytest-docker-tools is a Python package that provides pytest fixtures and helper functions for managing Docker containers in tests.

pytest-docker-tools provides pytest fixtures and helper functions for running Docker containers inside tests. It supports realistic integration testing when a production PostgreSQL database is unavailable, allowing hooks to use real database methods instead of mocked calls. section 10.2

PostgreSQL integration test

Define a movielens table through postgres-init.sql, start postgres:16-alpine with test credentials, and run a MovieLens-to-PostgreSQL operator against the real container.

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Demonstrates image fetching, fixture injection, container configuration, schema initialization, and operator testing without covering the full package API.
Examples
Uses a PostgreSQL image, dynamic port mapping, initialization SQL, a movielens table, and an Airflow operator test.
What it assumes
Assumes pytest and Docker availability, including permission for programs to use the Docker socket.
What you can do after
Apply it via pytest to test external-system integrations against a real PostgreSQL container.
How it connects
Connects pytest fixtures with Docker containers, PostgreSQL, integration testing, and mocking alternatives.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.