Code Monkey home page Code Monkey logo

wishlists's Introduction

wishlists

Build Status codecov

Wishlists RESTful service allows customers to create a collection of products that they wish they had the money to purchase.

Team: Hu Jianyuan, Omer Katz, Sakada Lim, Minh Lai, Doyeon Kong

Prerequisite Installation using Vagrant

The easiest way to use this lab is with Vagrant and VirtualBox. if you don't have this software the first step is down download and install it.

Download VirtualBox

Download Vagrant

Clone the project to your development folder and create your Vagrant vm

    git clone https://github.com/NYU-Wishlists/wishlists.git
    cd wishlists
    vagrant up

Once the VM is up you can use it with:

    vagrant ssh
    cd /vagrant
    python run.py

Alternatively you can also start by using honcho

    vagrant ssh
    cd /vagrant
    honcho start

Honcho makes use of the Procfile to start the service using Gunicorn similar to how one would start the server in production.

You should now be able to see the service running in your browser by going to http://localhost:5000. You will see a message about the service which looks something like this:

{
    name: "Wishlist Demo REST API Service",
    url: "http://localhost:5000/wishlists",
    version: "1.0"
}

When you are done, you can use Ctrl+C within the VM to stop the server.

Testing

Run the test using behave

    cd /vagrant
    python run.py &
    behave

Note that the & runs the server in the background. To stop the server, you must bring it to the foreground and then press Ctrl+C

Stop the server with

    fg
    <ctrl+c>

This repo also has a unit test that you can run with

    cd /vagrant
    nosetests

You should see all of the tests passing with a code coverage report at the end. This is controlled by the setup.cfg file in the repo.

Services

  • HealthCheck Check that the api is up and running.

    GET /healthcheck
    
  • Create a wishlist

    POST /wishlists
    

    Body example/format

    {
    "user": "Mikey", 
    "entries": 
      [{"id": 0, "name": "Mackbook"}, 
       {"id": 1, "name": " Iphone"}], 
    "name": "Mikes"
    }
    
  • Retrieve all wishlists

    GET /wishlists
    
    GET /
    

With a specific wishlist ID, you can perform the following action:

  • Read a wishlist with id, list all items in it

    GET /wishlists/<int:wishtlist_id>
    
  • Update a wishlist with id

    PUT /wishlists/<int:wishlist_id>
    
  • Delete a wishlist with id

    DELETE /wishlists/<int:id>
    

Other actions that can be performed:

  • Query with username, list all wishlists of a user

    GET /wishlists?wishlist_user=username
    
  • Action delete all wishlists of a user

    DELETE /wishlists/<string:user_name>/delete_all
    

Shutdown

When you are done, you can use the exit command to get out of the virtual machine just as if it were a remote server and shut down the vm with the following:

    exit
    vagrant halt

If the VM is no longer needed you can remove it with from your computer to free up disk space with:

    vagrant destroy

wishlists's People

Contributors

minhlai avatar jiayuanhu avatar sakadalim avatar okatz18 avatar okatzz avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar

Forkers

minhlai

wishlists's Issues

List all items of a wishlist

As a customer
I need an API to list the items
So that I can see the items of a particular wishlist of mine

Assumptions:
Each wishlist has an ID
A customer can only get her(his) own wishlist

Acceptance Criteria:

Given I have a wishlist with id x
When I do API call /wishlists/{id}/items
Then I get all the items in that wishlist

Refactor update wishlists method and add swagger doc

As a developer
I need to refactor /Update/ method and add swagger api doc
So that the app works on the cloud

Assumptions:

  • The /Update/ method that passed all the tests

Acceptance Criteria:

When the /Update/ method is called 
Then it should work the same as it did before refactoring with Swagger

Create a Python Flask Cloud Foundry application in IBM Cloud

As a ... Product Owner
I need ... a cloud microservice for wishlists
So that ... my customers can save their products.

Assumptions:

  • ... resource name must be singular
  • ... resource name must be prefixed by "nyu-" and suffixed by "-servicef18"

Acceptance Criteria:

Given ... an IBM cloud account
When ... I check the IBM cloud organization
Then ... I should see our application named, "nyu-wishlist-servicef18 and our URL should be nyu-
wishlist-service-f18.mybluemix.net

Refactor delete all wishlists for a user and add swagger doc

As a customer
I need a rest api to delete all wishlists for a user and swagger doc
So that I can see the documentation and delete at one click

Assumptions:
use restplus to automatically generate swagger doc

Acceptance Criteria:

Given the running service
When call DELETE /wishlists/{user_name}/delete_all
Then return HTTP_204_NO_CONTENT

Refactor get wishlists method and add swagger doc

As a developer
I need to refactor /Get/ method and add swagger api doc
So that the app works on the cloud

Assumptions:

  • The /Get/ method that passed all the tests

Acceptance Criteria:

When the /Get/ method is called 
Then it should work the same as it did before refactoring with Swagger

Add Persistence

As a ...
I need ...
So that ...

Assumptions:

  • ...

Acceptance Criteria:

Given ...
When ...
Then ...

Add Travis CI Badge

As a developer
I need to add a Travis CI badge to my README.md file
So that my project can display the test results from Travis CI

Assumptions:

  • Travis CI

Acceptance Criteria:

Given test cases
When I push new code
Then the badge in my Github readme file will update the results

List all wishlists

As a customer
I need to be able to see all the wishlists
So that I can browse all the wishlists that have been created so far

Assumptions:

  • API Call GET /wishlists
  • Should return the list with the name of all the wishlists

Acceptance Criteria:

When I go under the wishlists,
I see the list with the name of all the wishlists
If there is no wishlist created,
A message appears saying that no wishlist created so far

Refactor list wishlists method and add swagger doc

As a customer
I need a rest api to get all wishlists and swagger doc
So that I can see the documentation and all the wishlists

Assumptions:
use restplus to automatically generate swagger doc

Acceptance Criteria:

Given the running service
When call GET /wishlists/
Then return all the wishlists and 200

Write tests for model

As a ... Developer
I need ... to quickly write code and unit test it against our assumptions
So that ... I can quickly evaluate whether new code breaks any constraints.

Assumptions:

  • ... Test file will be named test_model.py
  • ... There should be tests for each of:
    • List Resources
    • Read a Resource
    • Create a Resource
    • Update a Resource
    • Delete a Resource
    • Query Resources by some attribute of the Resource
    • Perform some Action on the Resource

Acceptance Criteria:
...
Given ... The same code
When ... running nosetest against our model unit tests
Then ... that code should return the same result every time.
...

Add honcho to requirements.txt

As a ... Developer
I need ... honcho to run my app
So that ... I can run my app locally.

Assumptions:

  • ... I have a requirements.txt file in my repo
  • ... I have a procfile in my repo

Acceptance Criteria:

Given ... I run the command `honcho start`
When ... I am inside my VM
Then ... my application should start.

Query wishlist by its name

As a customer
I need an API call to query the wishlist
So that I can get my wishlist by its name

Assumptions:
Wishlists of a customer have unique names.

Acceptance Criteria:

Given the user id and a wishlist name x
When call /wishlists/find_by_name?name=x
Then return wishlist with name x for this user

Update Vagrantfile to download and install the IBM Cloud CLI

As a ... Developer
I need ... to install IBM Cloud CLI
So that ... I can use command line to access my Bluemix account.

Assumptions:

  • ... there is a good, functioning example on lab-bluemix-cf repo to reference

Acceptance Criteria:

Given ... I call vagrant up and vagrant ssh
When ... I am in my repo
Then ... I should be able to use command line to interface with IBM Cloud.

Delete all wishlists of a user

As a customer
I need an action based call
So that I can delete all wishlists of a user

Assumptions:

  • rest call should include data which indicates which user's wishlists to delete

Acceptance Criteria:

Given a user id
When call PUT /wishlists/<int:user_id>/deleteall
Then return empty wishlist and HTTP_200_OK

Standardize variable usage

Standardize paths and arguments

GET /healthcheck -- Check heart beat
GET  /wishlists/ - Retrieves a list of wishlists from the database
GET  /wishlists/{id}/items - Retrieves a Wishlist with a specific id
GET /wishlists?wishlist_user="username" - Retrieves the list of wishlists for a user
POST /wishlists - Creates a Wishlist in the datbase from the posted database
PUT  /wishlists/{id} - Updates a Wishlist in the database fom the posted database
DELETE /wishlists/{id} - Removes a Wishlist from the database that matches the id
DELETE /wishlists/{wishlist_name} - Removes all wishlists that match a name
DELETE /wishlists/{user_name}/delete_all - Removes all wishlists of a user

All use id, should modify user_name to user_id, change wishlist_user to user_id, all use id or wishlist_id to refer to wishlist id.

Create unit tests for our service

As a ... Developer
I need ... know if our Flask service works
So that ... so that our clients can use our API.

Assumptions:

  • ... Test file will be named test_service.py
  • ... There should be tests for each of Get, Post, Put, Delete actions

Acceptance Criteria:
...
Given ... The same code
When ... running nosetest against our service unit tests
Then ... that code should return the same result every time.
...

gunicorn command not starting service

All routes return 404 error in browser.

To Reproduce
Steps to reproduce the behavior:

  1. Go to URL of push Cloud Foundry app
  2. See 404 error

Expected behavior
URL should go to index page of API

Desktop (please complete the following information):

  • OS: Win10 and MacOS
  • Browser all browsers

Modify application to get database credentials from VCAP_SERVICES

As a application developer
I need my application to inject configs from environment variables
So that it connects with my cloud database in bluemix.

Assumptions:

  • I should not need to modify my application's logic model or server code

Acceptance Criteria:

When I start my application on Bluemix
Then it should be look for my Cloudant service to connect to.

Delete all of a user's wishlists

As a Customer
I need delete all my wishlists
So that my wife does not see my holiday shopping.

Assumptions:

  • userid is given

Acceptance Criteria:

Given  A list of wishlists
When  a customer requests to delete all their wishlists,
Then only their wishlists will be deleted.

Create metadata files for Cloud Foundry

As a ... Developer
I need ... metadata files for Cloud Foundry
So that ... my application builds and deploys correctly

Assumptions:

  • ... I need a runtime.txt
  • ... I need a manifest.yml
  • ... I need a procfile

Acceptance Criteria:

Given ... I deploy my application on IBM cloud
When ... IBM Cloud looks for the necessary files
Then ... they should be found in my repo.

Change routes to Restful Style

Expected

When call  GET /wishlists/{id}/items
Expect to get all the items in this wishlist

Possible fix

Change route for method get_wishlist() from /wishlists/{id} to  /wishlists/{id}/items

Add Swagger docs to our service

As a customer
I need information about API calls
So that I know how to call the services

Assumptions:
code has refactored to restplus

Acceptance Criteria:

Given running services 
When access /apidocs/index.html
Then see the documentation of APIs

Create IBM Cloud Organization

As a ... Developer
I need ... an IBM organization
So that ... my application can be deployed on the cloud

Assumptions:

  • ...

Acceptance Criteria:

Given ...
When ...
Then ...

Create a setup.cfg file

As a Test driven developer
I need to run my test suite
So that I can quickly test and deploy code.

Assumptions:

  • setup.cfg should have all our nosetests options

Acceptance Criteria:

Give That a dev types nosetests
Then  they should be able to run the test suite

Create a service.py file

As a microservice provider
I need a running web server and a bunch of microservices
So that I can provide relevant service to clients according to the accessing URL

Assumptions:

  • We will base on Flask to develop our services

Acceptance Criteria:

Given a running web server
When I issue an HTTP request to a certain URL
Then I will get the resources I asked for 

Update a wishlist

As a customer
I need to be able to update my wishlist
So that I can change specific items under the wishlist whenever I want to add/delete

Assumptions:

  • Customer ID is given
  • Wishlist name is given
  • Product ID is given

Acceptance Criteria:

Given the customer ID, wishlist name and product ID 
When the request for update is received 
Then the product ID is added/deleted to/from the wishlist

Create README.md

As a ... developer
I need ... to know the instructions for the code
So that ... I know what calls are available, what inputs is expected, and how to run and test the code

Assumptions:

  • ... Instruction should be written in clear plain English and easy to understand.

Acceptance Criteria:
...
Given readme file
When developer wants to access the API calls
Then he can loop up the file and find correct usage
...

Add cloudant storage to cloud application

As a client
I need save my wishlists
So that I can use them later.

Assumptions:

  • We will use Cloudant service on IBM Cloud as our persistence service

Acceptance Criteria:

When a client saves their wishlist 
Then there should be a wishlist object saved in our database

Add Codecov badge to README.md

As a developer
I need to add a code coverage badge to README.md file
So that I can check out how much of our code is tested and therefore reduce chances for bugs

Create a vagrantfile

As a ... developer
I need ... quickly launch my work environment
So that ... I can develop on the same environment as my team.

Assumptions:

  • ... vagrant file should install all the needed dev and testing software

Acceptance Criteria:
...
Given ... A team member does vagrant up && vagrant ssh
Then ... they should be able to start developing
...

Create a model.py file

As a microservice developer
I need a model file
So that all model definitions of resources can be held clearly.

Assumptions:

  • Our microservice will mostly base on these models

Acceptance Criteria:

Given model.py
When access any model in the file
Then all the features can be retrieved

Modify models.py to add persistence

As a Client
I need to save my wishlists
So that I can view them later

Assumptions:

Acceptance Criteria:

When I call save or query for a wishlist
Then a nosql database should store or query for that wishlist

Write a requirement file for vagrant

As a ... developer
I need ... my vagrant environment to have every software I need
So that ... I can start working quickly every time I pick up.

Assumptions: Need to include

  • ... pinocchio
  • ... Nosetests
  • ... Flask
  • ... SQLAlchemy
  • ... pylint
  • ... Code Coverage

Acceptance Criteria:
...
Given ...
When ...
Then ...
...

Refactor delete wishlists method and add swagger doc

As a developer
I need to refactor /Delete/ method and add swagger api doc
So that the app works on the cloud

Assumptions:

  • The /Delete/ method that passed all the tests

Acceptance Criteria:

When the /Delete/ method is called 
Then it should work the same as it did before refactoring with Swagger

Create .gitignore

As a ... developer-collaborator
I need ... to share my code with my team without sharing transient files
So that ... we can work together and see only the necessary code

Assumptions:

  • ... Team members will be working across different OSes and programming environment.
    gitignore should be extensive.

Acceptance Criteria:
...
Given ...
When ... committing
Then ... transient files your working directory that isn't useful to other collaborators, such as compilation products, temporary files IDEs create, etc, should not be committed to the shared code base.
...

Add Swagger docs to wishlists service

As a developer
I need standardized documentation to document what our API does by adding Swagger docs to our service
So that Swagger tools document our API using Flask-RESTPlus

Assumptions:

Given our API updates, our documentation stays up-to-date 

Acceptance Criteria:

The documentation API must be at: /apidocs/index.html

Delete a wishlist

As a customer
I need to be able to delete a wishlist
So that I can delete a wishlist I no longer wish to have.

Assumptions:
*

Acceptance Criteria:

Given that there is there is a few wishlists belonging to a user,
When I want to remove one, I can do so with its name or id.
Then the wishlist is deleted.

Missing base report

As a developer
I need to fix a missing base report to integrate this project with Codecov
So that Codecov can compare commits and run successfully on Travis CI

Given the base of the pull request that uploaded a coverage report,
Codecov can produce an accurate coverage comparison with the coverage report for the pull request base.

pip upgrade issue

As a ... developer
I need ... have pip update in vagrant
So that ... I can start using pip with vagrant

Assumptions:

  • ...

Acceptance Criteria:

Given ... vagrant up
When ... we load vagrant
Then ... pip is upgraded to the latest version and working 

Set up the DevOps Pipeline in IBM Cloud (Build)

As a developer
I need a DevOps pipeline
So that it will automatically build and deploy our service

Assumptions:
The pipeline is built on IBM Cloud
Build, Dev for sprint 4

Acceptance Criteria:

Given a DevOps pipeline connected to the GitHub repository
When a commit is made to the repo
Then it will run unit tests with nosetests and deploy if unit tests pass 

Document API in readme file

As a customer
I need instructions for APIs
So that I can access the APIs

Acceptance Criteria:

Given readme file
When user wants to operate on resources
Then it can look up the file and know what to do

Refactor add wishlist method and add swagger doc

As a customer
I need a rest api to add a wishlist and add swagger api doc
So that I can see the documentation and add a wishlist

Acceptance Criteria:
use restplus to automatically generate swagger doc

Given the running service
When call POST /wishlists/
Then return the wishlist created and HTTP response 201

Add ability to specify Wishlist name in `GET /wishlists`

As a ... Client
I need ... to be able to query based on my username and wishlist name
So that ... I do not need the Wishlist ID

Assumptions:

  • ... I can modify the GET /wishlists route with an additional query string for the wishlist name

Acceptance Criteria:

Given ... A username and wishlist name
When ... creating a GET request to /wishlists
Then ... I should get a list of a single wishlist if that wishlist exists

Create a wishlist

As a customer
I need to be able to create a new wishlist with a unique names
So that I can save all the items I want

Assumptions:

  • We have customer IDs
  • Each wish list has a unique name

Acceptance Criteria:

Given that each customer has a differentiable ID
When the customer asks for items by wishlist name
Then the customer can get a wishlist with an id and a name

Create a .travis.yml file and configure Travis CI

As a developer
I need to create a travis file and configure travis CI
So that I can run test cases every time someone pushes to the master branch or submits a pull request.

Assumptions:

  • The master branch should always be ready to be deployable.

Acceptance Criteria:

Every commit pushed to master branch and pull request should be passed all tests without failing.

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.