Skip to content

iagovirgilio/django-tdd-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TDD DJANGO

Test Driven Development with Django

DOCKER

1. Run this commands:

  • Up
docker compose build
docker compose up -d
  • Down
docker compose down
  • Down (remove volume)
docker compose down -v
  • Re-Build
docker compose up -d --build
```doc

### 2. Run the migrations:
```bash
docker compose exec movies python manage.py migrate --noinput

3. Check that the volume was created as well by running:

docker volume inspect django-tdd-docker_postgres_data

4. Seed database

docker compose exec movies python manage.py flush
docker compose exec movies python manage.py loaddata movies.json

5. Generate SECRET_KEY

docker compose exec movies python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

HTTPie

Test insert

http --json POST http://localhost:8009/api/movies/ title=Fargo genre=comedy year=1996

Get all movies

http --json http://localhost:8009/api/movies/

Get single movie

http --json http://localhost:8009/api/movies/1/ 

Pytest Commands

  • Normal run

    docker compose exec movies pytest
  • Disable warnings

    docker compose exec movies pytest -p no:warnings
  • Run only the last failed tests

    docker compose exec movies pytest --lf
  • Run only the tests with names that match the string expression

    docker compose exec movies pytest -k "movie and not all_movies"
  • Stop the test session after the first failure

    docker compose exec movies pytest -x
  • Enter PDB after first failure then end the test session

    docker compose exec movies pytest -x --pdb
  • Stop the test run after two failures

    docker compose exec movies pytest --maxfail=2
  • Show local variables in tracebacks

    docker compose exec movies pytest -l
  • list the 2 slowest tests

    docker compose exec movies pytest --durations=2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published