Cguilliman / hexagonal-architecture-django

Experiments with Django and Hexagonal Architecture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hexagonal-architecture-django

Experiments with Django and Hexagonal Architecture

Installation

python3 -m venv .venv     
. .venv/bin/activate
pip install -r requirements.txt

Static type checks (mypy)

export MYPYPATH=src/ 
mypy --namespace-packages -v -p myapp

Run unit tests

export PYTHONPATH=${PYTHONPATH}:./:src/
pytest

Run application

./src/manage.py migrate
./src/manage.py runserver

Test with cURL:

With existing user:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"user_id": "e47cec00-c22a-486d-afe6-e76902f211c1", "article_id": 
  "60ccea0c-0bf2-4726-8ac7-324fa03a74cd", "vote": "UP"}' \
  http://localhost:8000/api/article_vote

Non-existing user:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"user_id": "efed6f83-49ee-4cbc-bdbd-2b92bf428f2b", "article_id": 
  "60ccea0c-0bf2-4726-8ac7-324fa03a74cd", "vote": "UP"}' \
  http://localhost:8000/api/article_vote

About

Experiments with Django and Hexagonal Architecture

License:MIT License


Languages

Language:Python 99.5%Language:Makefile 0.5%