This repo serves as an example for doing integration tests with fastAPI and pytest.
Checkout the accompanying post https://alex-jacobs.com/posts/fastapitests/
Contained is a toy fastAPI app with simple JWT auth and some endpoints to serve as good examples for making integration / API tests.
In tests
thee are a number of examples using different patterns for integration testing fastAPI applications.
either use poetry or pip to install the dependencies
poetry install
or
pip install -r requirements.txt
pytest
uvicorn app.main:app --reload
docker build -t fastapi-integration-tests .
docker compose up
or
docker run -p 8000:8000 fastapi-integration-tests