Skip to content

MohamedElaassal/FastAPI-TDD-Async-Practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI TDD Async Practice

A small FastAPI project that builds and tests an asynchronous API with Postgres, Docker, and pytest.

What this repo is

This is a learning-focused CRUD sample that shows how to:

  • Build async endpoints with FastAPI.
  • Connect to Postgres with async drivers.
  • Write API tests with pytest and httpx.
  • Run everything with Docker Compose.

Project layout

  • src/app: FastAPI application code
  • src/test: pytest tests
  • src/requirements.txt: Python dependencies
  • src/Dockerfile: app container image
  • docker-compose.yml: app + database services

Getting started

  1. Build and start the stack
docker-compose up --build
  1. Check the API
http http://localhost:8002/ping
  1. Create a note
http --json POST http://localhost:8002/notes/ title=foo description=bar

Running tests

You can run tests inside the app container:

docker exec -it fastapi-crud-web-1 pytest

Notes

  • The app uses a bind mount in Docker Compose, so code changes apply immediately.
  • If you change dependencies, rebuild the image.

About

Developing and Testing an Asynchronous API with FastAPI and Pytest

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors