Giter Site home page Giter Site logo

trellixvulnteam / myproject_fof7 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anudeepchen/myproject

0.0 0.0 0.0 16.56 MB

Shell 0.02% JavaScript 12.86% C++ 0.53% Python 80.64% C 2.20% PowerShell 0.04% CSS 2.72% HTML 0.75% Batchfile 0.25% Procfile 0.01%

myproject_fof7's Introduction

#Testing Guide

##Installations required for Testing the REST framework:

Create the project directory

mkdir testing cd testing

Create a virtualenv to isolate our package dependencies locally

virtualenv env source env/bin/activate # On Windows use env\Scripts\activate

Install Django and Django REST framework into the virtualenv

pip install django

pip install djangorestframework

Install HTTPIE

pip install httpie

###Description: A basic REST API service built using Django and Python. The web service works as a simple discussion board where registered users can create topics and add comments to the topic. It also allows the registered users to edit the existing comments. As part of exercise 2 application allows the multiple users to edit the existing comments without losing the information. It keeps track of the when was the particular content was last modified. So the users get to access the latest comment.

###Unit Testing: I have created two applications topics and comments. The test cases are included in their respective tests.py file.

#####To run the unit test in command prompt run:

python manage.py test

Testing on Web Browser:

#####To run the application on the web browser:

In Command prompt run: python manage.py runserver

  1. Get all registered Users : Paste the link on browser: http://127.0.0.1:8000/users/ alt text

  2. Get a particular User: Paste the link on browser: http://127.0.0.1:8000/users/ 1/ alt text

  3. Get all topics : Paste the link on browser : http://127.0.0.1:8000/topics/

alt text

  1. Get a particular Topic: Paste the link on browser : http://127.0.0.1:8000/topics/1/ alt text

  2. Get all comments of a topic: Paste the link on browser : http://127.0.0.1:8000/topics/7/comments/ alt text

  3. Create a Topic : In command Prompt : http -a anudeep:123456 --json POST http://127.0.0.1:8000/topics/ title="New Topic" alt text

  4. Delete a topic: In command Prompt : http -a anudeep:123456 --json DELETE http://127.0.0.1:8000/topics/4/ and http://127.0.0.1:8000/topics/4/

alt text

###Comment Section with Etags and Last modified In a new Command prompt window run the below commands to test the application

  1. Get Comments :

http -a Anudeep:123456 –json GET http://127.0.0.1:8000/topics/1/comments/3/

alt text

2.GET- If_None_Match:

http -a Anudeep:123456 –json GET http://127.0.0.1:8000/topics/1/comments/3/ “If-None-Match:\“ 4aab95a43eee364d47203fbffc2f5f8d\””

alt text

3.PUT : If-Match header is not passed, the application should prompt user to provide Precondition

http -a Anudeep:123456 –json PUT http://127.0.0.1:8000/topics/1/comments/3/ comment=“Modify the Comment with Put Statement” alt text

4.PUT – Invalid Etag is passed: Application throws message PRECONDITION FAILED http -a Anudeep:123456 –json PUT http://127.0.0.1:8000/topics/1/comments/3/ comment=“Modify the Comment with Put Statement” “If-Match:\“ Invalid Value\””

alt text 5.PUT :

User provides valid credentials along with If-Match header with correct Etag and comment http -a Anudeep:123456 –json PUT http://127.0.0.1:8000/topics/1/comments/3/ comment=“Modify the Comment with Put Statement” “If-Match:\“ 4aab95a43eee364d47203fbffc2f5f8d\””

alt text

6.DELETE : Delete follows same rules as PUT statement

myproject_fof7's People

Contributors

anudeepchen avatar trellixvulnteam 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.