Project

Python testing pyramid lab

Python testing project built around a minimal FastAPI SUT to show how to apply the testing pyramid with a clear, reproducible and easy-to-extend base.

Overview

Python testing project focused on the testing pyramid around a minimal FastAPI SUT, with unit tests for business logic, API integration tests with FastAPI TestClient and input validation with Pydantic. The project also includes an implementation with SQLite persistence to compare fast tests and tests with real storage, and applies CI quality gates with ruff, pytest and coverage.

Stack: Python, FastAPI, Pytest, SQLite, Ruff, GitHub Actions

What it does

The project aims to show how to distribute tests according to their cost and scope, avoiding dependence only on slow or overly coupled tests. To do this, it combines quick business-logic validation, API integration checks and a variant with real persistence.

How it is built

The solution is based on a minimal FastAPI application with input validation through Pydantic, organised to test business rules, endpoints and persistence behaviour. In addition to the lighter version, it includes an implementation with SQLite to compare scenarios without real storage and scenarios with a real database.

What it validates or automates

The workflow runs unit and integration tests with pytest and FastAPI TestClient, and applies CI quality gates with ruff, pytest and coverage. This makes it possible to quickly check the main logic, validate API responses and measure coverage with reproducible execution locally and in GitHub Actions.

Key points