Repository to learn and explore API and Backend service with Python using FastAPI Framework
- uv
0.8.15 - make
3.81 - git
latest - pycharm
latest
settings -> Python -> Integrated Tools -> Testing -> Default test runner -> pytest
make
Note:
Set the environment variable TESTCONTAINERS_RYUK_DISABLED as true to disable RYUK (TestContainer) while running the build
make init_dependencies
Docker dependencies needs to be started using docker compose before running the build or starting the api
docker compose -f docker-compose.yml pull
docker compose -f docker-compose.yml up --build -d
docker compose -f docker-compose.yml down -v
make fast_dev
http://localhost:8000/docs
http://localhost:8000/context/docs
make fast_run
http://localhost:80000/docs
http://localhost:8000/context/docs
Run all tests in a directory or module
make tests_unit_specific UNIT_TEST=tests_unit/dao
Run all tests in a file
make tests_unit_specific UNIT_TEST=tests_unit/dao/test_customer_dao.py
Run a specific test function
make tests_unit_specific UNIT_TEST=tests_unit/dao/test_customer_dao.py::test_customers_insert
Run all tests in a directory or module
make tests_integration_specific INTEGRATION_TEST=tests_integration/routers
Run all tests in a file
make tests_integration_specific INTEGRATION_TEST=tests_integration/routers/test_customer.py
Run a specific test function
make tests_integration_specific INTEGRATION_TEST=tests_integration/routers/test_customer.py::test_customers_insert_read_delete
Create docker image
docker build --pull -t python-fastapi -f Dockerfile .
Run the created docker image
docker run -it --rm --network=python-fastapi-network -e 'APP_DB_HOST=python-fastapi-postgres' -e 'APP_EXTERNAL_FAQ_API_BASE_URL=http://prism-mock-open-api:4010' -e 'PORT=8000' -p 8000:8000 python-fastapi
http://localhost:8000