Git Product home page Git Product logo

tdd-django-docker-project's Introduction

Test-Driven Development with Django, Django REST Framework, and Docker

Tech stack

  • Python 3.10
  • Django 4.1.2
  • Django REST Framework 3.14.0
  • pytest
  • Docker
  • GitLab CI
  • RESTful API
  • render

API Overview

Endpoint HTTP Method CRUD Method Result
/api/movies GET READ get all movies
/api/movies/:id GET READ get a single movie
/api/movies POST CREATE add a movie
/api/movies/:id PUT UPDATE update a movie
/api/movies/:id DELETE DELETE delete a movie

Folder structure

git ls-tree -r --name-only HEAD | tree --fromfile

.
├── .gitignore
├── .gitlab-ci.yml
├── README.md
├── app
│   ├── Dockerfile
│   ├── Dockerfile.prod
│   ├── conftest.py
│   ├── drf_project
│   │   ├── __init__.py
│   │   ├── asgi.py
│   │   ├── manage.py
│   │   ├── settings.py
│   │   ├── urls.py
│   │   ├── views.py
│   │   └── wsgi.py
│   ├── entrypoint.sh
│   ├── manage.py
│   ├── movies
│   │   ├── __init__.py
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── migrations
│   │   │   ├── 0001_initial.py
│   │   │   ├── 0002_movie.py
│   │   │   └── __init__.py
│   │   ├── models.py
│   │   ├── serializers.py
│   │   ├── urls.py
│   │   └── views.py
│   ├── movies.json
│   ├── pytest.ini
│   ├── requirements.txt
│   ├── setup.cfg
│   └── tests
│       ├── __init__.py
│       ├── movies
│       │   ├── __init__.py
│       │   ├── conftest.py
│       │   └── test_views.py
│       ├── test_foo.py
│       ├── test_models.py
│       └── test_serializers.py
└── docker-compose.yml

6 directories, 37 files

Note

If you use m1/m2 chip macbook, remember to export DOCKER_DEFAULT_PLATFORM=linux/amd64 before building/running the image.

Some useful command

# Start app
$ docker-compose up -d --build

# Run the tests with coverage
$ docker-compose exec movies pytest -p no:warnings --cov=.

# Want to view an HTML version
$ docker-compose exec movies pytest -p no:warnings --cov=. --cov-report html

# Run Flake8
$ docker-compose exec movies flake8 .

# run Black
$ docker-compose exec movies black --check --exclude=migrations --exclude=env .

# Try running it with the diff option as well before applying the changes
$ docker-compose exec movies black --diff --exclude=migrations .
$ docker-compose exec movies black --exclude=migrations .


# Run it with the check-only and diff options
$ docker-compose exec movies isort . --check-only
$ docker-compose exec movies isort . --diff

# apply the changes
$ docker-compose exec movies isort .


# Verify one last time that Flake8, Black, and isort all pass:
$ docker-compose exec movies pytest -p no:warnings --cov=.
$ docker-compose exec movies flake8 .
$ docker-compose exec movies black --check --exclude=migrations --exclude=env .
$ docker-compose exec movies isort . --check-only

tdd-django-docker-project's People

Contributors

yysu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.