GithubHelp home page GithubHelp logo

pigaov10 / admin_dispatcher Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 36 KB

Django Test Coding

Home Page: http://luizalabs.com/

Python 100.00%
django api python testing employee django-rest-framework conda-environment

admin_dispatcher's Introduction

Build Status | |

Linguagem / Framework / Banco de dados

Ferramentas auxiliares

Instalação

  • Crie um virtualenv e.g $ conda create --name myenv python=3.6
  • Ative o virtualenv e.g $ source activate myenv
  • Clone o repositório $ git clone https://github.com/pigaov10/desafio.git luizalabs; cd luizalabs
  • Instale as dependencias $ pip install -r requirements.txt

Migração

$ cd builder
$ python manage.py makemigrations manager
$ python manage.py migrate
$ python manage.py createsuperuser

Linters

$ pyflakes .
$ pylint .
$ pep8 .

Testes

$ python manage.py test manager/tests.py --with-coverage

Inicie o servidor e acesse o Admin Employee

$ python manage.py runserver

http://127.0.0.1:8000/admin/ Entre com o usuário que foi cadastrado no createsuperuser Cadastre um Departamento e um Employee, após isso você poderá acessar a API

API

Via Browser, você poderá acessar o Admin do Django REST Framework http://127.0.0.1:8000/employees/ Via Curl adicione o comandos abaixo: (Obs: Autenticacao é feita com usuario do ADMIN)

Lista todos os Employee

RESPONSE CODE
OK HTTP_20O_SUCCESS
ERRO HTTP_400_BAD_REQUEST
$ curl -X GET \
  http://127.0.0.1:8000/employees/ \
  -u <username>:<password>

Lista Específico Employee

RESPONSE CODE
OK HTTP_20O_SUCCESS
ERRO HTTP_404_NOT_FOUND
$ curl -X GET \
  http://127.0.0.1:8000/employee/<id>/ \
  -u <username>:<password>

Deletar Específico Employee

RESPONSE CODE
OK HTTP_204_NO_CONTENT
ERRO HTTP_400_BAD_REQUEST
$ curl -X DELETE \
  http://127.0.0.1:8000/employee/<id>/ \
  -u <username>:<password>

Criar Employee

RESPONSE CODE
OK HTTP_201_CREATED
ERRO HTTP_400_BAD_REQUEST
$ curl -X POST http://127.0.0.1:8000/employees/ \
  -u <username>:<password>  \
  -d "name=Albert Einstein&[email protected]&department_id=1"

Resposta:

{
    "name": "Albert Einstein",
    "department": {
        "department_id": 1,
        "name": "RH"
    },
    "email": "[email protected]",
    "employee_id": 4
}

Acesso Negado

{"detail":"Authentication credentials were not provided."}

Usuário já cadastrado

{
    "email": [
        "employee with this email already exists."
    ]
}

admin_dispatcher's People

Contributors

pigaov10 avatar

Stargazers

Daniel Bruno avatar

Watchers

James Cloos avatar  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.