GithubHelp home page GithubHelp logo

orders's Introduction

Bluemix Python Web application

Build Status codecov

This repository if for Team Bravo Orders Project.

Follow the steps below to get the code up and running locally.

Prerequisite : Vagrant and VirtualBox

Get the code

From a terminal navigate to a location where you want this application code to be downloaded to and issue:

    $ git clone [email protected]:NYU-DevOps-S17/Orders.git
    $ cd Orders
    $ vagrant up
    $ vagrant ssh
    $ cd /vagrant

This will place you into an Ubuntu VM all set to run the code.

You can run the code to test it out in your browser with the following command:

$ python run.py

You should be able to see it at: http://localhost:5000/

Swagger doc page: http://localhost:5000/apidocs/index.html

When you are done, you can use Ctrl+C to stop the server and then exit and shut down the vm with:

$ vagrant halt

BlueMix deployment

Once there is an update on the master branch, BlueMix will auto build/deploy the latest working copy.

BlueMix URL: https://nyu-devops-orders-prod.mybluemix.net/
BlueMix Swagger doc page: https://nyu-devops-orders-prod.mybluemix.net/apidocs/index.html?url=/v1/spec
BlueMix docker container deploy: https://hello-containers-20170426230123948.mybluemix.net/

BDD / TDD tests command when running locally

Use the following commands to test BDD and TDD results.

    BDD: $ behave
    TDD: $ nosetests

Structure of application

Procfile - Contains the command to run when you application starts on Bluemix.

requirements.txt - Contains the external python packages that are required by the application.

runtime.txt - Controls which python runtime to use. In this case we want to use 2.7.9.

README.md - this readme.

manifest.yml - Controls how the app will be deployed in Bluemix and specifies memory and other services like Redis that are needed to be bound to it.

app folder - The folder where the python application script stored.

old-files folder - The folder containing old lab code.

features folder - The folder containing BDD tests feature file and steps.

tests folder - The folder containing TDD tests py files.

orders's People

Contributors

juderuben avatar kehanwu avatar maskyyoung avatar matthewchiappa avatar vignesh3193 avatar

Watchers

 avatar  avatar  avatar  avatar

orders's Issues

Add Persistence to the REST api

As a api user of the orders resource
I need a way to keep information about the orders I modify
So that I can shut down and turn on the server

Assumptions:

  • The data I change in the database should remain when I start the server again

Acceptance Criteria:

Given I change or create an order
When I shut down the server
Then the order should be changed or in the database when I turn it back on

Fix test_orders to use server redis

As a Developer
I need to use redis on Bluemix
So that all the tests will pass and redis service can be up and running

Acceptance Criteria:

Given adding a test stage in Bluemix devops pipeline
When changes pushed to master branch
Then I should see build - test - deploy stages passed without errors on the pipeline

Create Swagger Docs for the Rest API

As a consumer of the orders resource
I need a way to have living documentation
So that orders can know what the API is capable of

Assumptions:

  • This will be done with flasger and swaggerdocs

Acceptance Criteria:

Given I navigate to http://localhost:5000/apidocs/index.html
When I get to the page
Then I should see the documentation of the API

Add a database to the vagrantfile

As a api user of the orders resource
I need a way to keep information about the orders I modify
So that I can shut down and turn on the server

Assumptions:

  • The database should work with the Vagrantfile

Acceptance Criteria:

Given I change or create an order
When I shut down the server
Then the order should be changed or in the database when I turn it back on

Convert features folders to orders

As a API user
I need to access the orders resource
So that I can get, create and change orders in the database

Assumptions:

  • All pets references must be changed to our orders resource

Acceptance Criteria:

Given I have an order I want to create, update, delete or retrieve
When I access the resource with the API
Then I am able to preform all CRUD actions

Add persistence in the code

As a user
I need persistence on data
So that I don't lose data when restarting service

Assumptions:

  • The data should not disappear when service restarts

Acceptance Criteria:

Given the current orders
When I restart service
Then the current orders still exist

The user should be able to query for a order through the API

As a user of the REST API
I need to get a list of orders with a specific field
So that I can use this information to collect data

Assumptions:

  • Query parameters belong at the end of the uri ex. /orders?foo=bar

Acceptance Criteria:

Given I want to access the /orders resource
When I attempt to filter the orders with an index call
Then the service should return the orders that have that fiekd

Re-organize the root folder

As a Developer
I need to have the root folder setup properly
So that I have BDD/TDD and my code can run on Bluemix with CI/CD

Assumptions:

  • Auto-deploy on Bluemix

Acceptance Criteria:

Given new change made to master branch
When I launch my bluemix URL
Then I should see the app auto-deployed with tests passed

Add a home page for orders

As a Retailer
I need a home page to display all the orders that were placed
So that we can view or edit the orders

Assumptions:

  • The home page will be called 'index.html'

Acceptance Criteria:

When I navigate to the URL
I should see the page with all the orders that were placed

Package the code to a local docker container

As a developer
I need to package my code into a docker container
So that i can deploy faster and make the service scalable

Acceptance Criteria:

Given the docker container
When I run the container
Then I should see the service up and running on localhost

Deploy database with Bluemix

As a api user of the orders resource
I need a way to keep information about the orders I modify
So that I can shut down and turn on the server

Assumptions:

  • The database should work on Bluemix

Acceptance Criteria:

Given I change or create an order
When I shut down the server
Then the order should be changed or in the database when I turn it back on

CRUD actions for the /orders resource

As a user of the REST API
I need basic create, read, update, and delete on the resource
So that I can perform actions to modify orders

Assumptions:

  • The resource CRUD actions should follow correct REST API guidelines

Acceptance Criteria:

Given I want to access the /orders resource
When I attempt to create, read, update, and delete orders
Then the service should correctly preform these actions

Add a unit test to test for our duplicate action

As a API user
I need to test the orders resource
So that I can test for the duplicate action

Acceptance Criteria:

Given I run the test suite
When I want to test the duplicate functionality
Then I should have a test that covers this scenario

Fix BDD tests

As a Developer
I need BDD Testing
So that Tests can run before I deploy

Assumptions:

  • BDD Testing

Acceptance Criteria:

Given I have the service running
When I run 'behave' command
Then I should see all tests pass

Setup Travis CI

As a developer
I need Continuous integration
So that my tests can run before i merge the code

Enable the user to create an order

As a user of the REST API
I need basic create on the resource
So that I can perform this action to create an order

Assumptions:

  • The user should create an order an be returned the id and information about that order

Acceptance Criteria:

Given I want to access the /orders resource and create an order
When I attempt to create the order
Then the id as well as the order information should be returned

Create a vagrantfile

As a Developer
I need vagrant file
So that other developers can download and have the same VM image

Assumptions:

  • It should be called 'vagrantfile'

Acceptance Criteria:

After download and replace the vagrantfile
I can initialize the VM by running 'vagrant up' command
I can access the VM by running 'vagrant ssh' command
I can access the default homepage by typing 127.0.0.1:8080 in a local browser

Deploy docker container to Bluemix

As a Developer
I need my local docker container deployed on Bluemix
So that I can have my service running on the Bluemix container cloud

Acceptance Criteria:

Given the docker container deployed 
When I go to the docker container cloud URL
Then I should see my service up and running on Bluemix

Convert app folder to orders

As a API user
I need to access the orders resource
So that I can get, create and change orders in the database

Assumptions:

  • All pets references must be changed to our orders resource

Acceptance Criteria:

Given I have an order I want to create, update, delete or retrieve
When I access the resource with the API
Then I am able to preform all CRUD actions

The user should be able to delete an order by its id

As a user of the REST API
I need to delete an order
So that I can remove the order from memory

Assumptions:

  • A response should be returned on completion of deleting the order

Acceptance Criteria:

Given I want to access the /orders resource
When I attempt to delete an order
Then the service should remove the order from memory

Convert tests folder to orders

As a API user
I need to access the orders resource
So that I can get, create and change orders in the database

Assumptions:

  • All pets references must be changed to our orders resource

Acceptance Criteria:

Given I have an order I want to create, update, delete or retrieve
When I access the resource with the API
Then I am able to preform all CRUD actions

[SPIKE] Add an action to the REST API

This needs to be discussed with the team. We need to come up with a useful action that could be used with the orders resource.

From Slack:
John Rofrano [5:07 PM]
Tip on Creating Actions

Some of you may be struggling to come up with an action for your API. Here are some things to consider:

The purpose of an action is usually to change the state of the resource in a very definite way that simply changing an attribute might not or cannot accomplish. The example I gave in class was:
'PUT /servers/{id}/reboot'

Servers are usually running or stopped so you need an action like reboot to cycle through from running to stopped to running again which cannot be expressed by a simple state change.

Setup BlueMix

Setup Bluemix following the instructions from slides

Setup Bluemix Test Stage in DevOps pipeline

As a Developer
I need a Test stage in my pipeline
So that BDD will run before deploy to prod

Acceptance Criteria:

Given Bluemix DevOps pipeline
When I commit a change to master branch
Then I should see all tests passed and my app ready to be deployed to prod

Enable the user to be able to retrieve an order by its id number

As a user of the REST API
I need basic read an order on the resource
So that I can find information about the order

Assumptions:

  • Only an id is needed to retrieve the order

Acceptance Criteria:

Given I want to access the /orders resource
When I attempt to retrieve an order by its id
Then the service should correctly return that order along with its information

Build skeleton of REST api from the example given in class

As a user of the orders resource
I need the REST api to run
So that I can hit a resource on the application

Assumptions:

  • The resource should be able to run.

Acceptance Criteria:

Given I want to access the orders resource
When I attempt to hit the url that the resource resides on
Then I will get a response from the service

The user should be able to get a list of all the orders with an index call

As a user of the REST API
I need to retrieve all orders that are stored
So that I can see all of the orders in one place

Assumptions:

  • The resource should return all orders when /orders is called

Acceptance Criteria:

Given I want to access the /orders resource
When I attempt to retrieve all the orders with /orders
Then the service should respond with all the orders that are stored

Add behave test to cover duplicate action

As a API user
I need to test the orders resource
So that I can test for the duplicate action

Acceptance Criteria:

Given I run the test suite
When I want to test the duplicate functionality
Then I should have a test that covers this scenario

Setup Bluemix Deploy to Prod stage in DevOps pipeline

As a Developer
I need a Deploy to Prod stage in my pipeline
So that my app will deploy to prod env

Acceptance Criteria:

Given Bluemix DevOps pipeline
When I commit a change to master branch
Then I should see all tests passed and my app deployed to prod

The user should be able to update an order by its id

As a user of the REST API
I need to update information of an order
So that I can change the information that is stored with the order

Assumptions:

  • The information about resource should be changed after update

Acceptance Criteria:

Given I want to access the /orders resource
When I attempt to update an order
Then the service should correctly update the information about that order

Add action to orders resource that duplicates an order

As a User of the REST API
I need duplicate an order
So that a person using the system can reorder an item

Assumptions:

  • The order should have the exact same information, but the id will be different than the original one

Acceptance Criteria:

Given I need have a customer who needs to reorder
When I use the action /orders/<some_id>/duplicate
Then the order should be duplicated and have a different id

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.