Skip to content

gpicavet/registration-demo

Repository files navigation

Registration Demo

Install and Test

Start the stack ::

$ docker-compose up

Register::

$ curl -H "Content-Type: application/json" localhost:8000/api/register -d "{\"email\":\"[email protected]\",\"password\":\"aaaaaaaaaaaa\"}"

Check the "mail" in docker-compose output ::

"json": {
    "to": "[email protected]",
    "from": "[email protected]",
    "body": "Hello, here is your activation code 1234. Please go to /api/activate"
}

Activate your account ::

$ curl -H "Content-Type: application/json" -u "[email protected]":aaaaaaaaaaaa localhost:8000/api/activate -d "{\"activation_code\":\"1234\"}"

Run Integration Tests with Docker

this will override starting command to run pytest with coverage report ::

docker-compose -p tests run -v /var/run/docker.sock:/var/run/docker.sock --rm registration-api sh -c "pip install '.[test]' && coverage run -m pytest && coverage report"

Architecture

architecture.png

Install DEV

Create a virtualenv and activate it::

$ python3 -m venv venv
$ . venv/bin/activate

Install dependencies::

$ pip install -e .

Run DEV

::

$ docker-compose up database mail
$ export FLASK_APP=main FLASK_ENV=development PGHOST=localhost PGUSER=demo PGPASSWORD=demo PGDATABASE=registration PGPORT=5432 MAIL_URL=http://localhost:8025
$ flask run

Open http://127.0.0.1:5000 in a browser.

Test DEV

::

$ pip install '.[test]'
$ pytest

Please wait until the docker images are downloading !

Run with coverage report::

$ coverage run -m pytest
$ coverage report
$ coverage html  # open htmlcov/index.html in a browser

About

simple User Registration api using Python & Flask

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published