Code Monkey home page Code Monkey logo

promotions's Introduction

Promo

Promotions Resource

A RESTful microservice based on a resource from an eCommerce application

travis codecov contributors license

Introduction « Overview « Setup « Attributes « Functions « Featured « Tests « License

👋 Introduction

The promotions resource is a representation of a special promotion or sale that is running against a product or perhaps the entire store. Some examples are "buy 1 get 1 free", "20% off", etc. Discount promotions usually apply for a given duration (e.g., sale for 1 week only).

👀 Overview

This project's /service folder contains a file for the Promotion model and a service.py file for promotions service. The /tests folder has test case code for testing the model and the service separately.

💾 Setup

To run this project, clone this repository and install vagrant virtual machine . Next, initialize a vagrant enviroment using vagrant up. Then do:

vagrant ssh
cd /vagrant
nosetests
honcho start

⚙️ Attributes

The Promotion Model contains the following attributes:

  • "name"
  • "description"
  • "start_date"
  • "end_date"

🛠 Functions

The following lists the RESTful routes:

Endpoint           Methods  Rule                                Description
----------------   -------  ----------------------------        -------------------------
index              GET      /                            

create_promotions  POST     /promotions                         create a promotion object and adds it to the database
get_promotions     GET      /promotions/<promotion_id>          return the information for a specified promotion
update_promotions  PUT      /promotions/<promotion_id>          edit and save changes to a promotion
delete_promotions  DELETE   /promotions/<promotion_id>          remove a promotion from the database
list_promotions    GET      /promotions                         list all promotions in the databas
search_promotions  GET      /promotions/<params>                search the database for promotions that match the query parameters
cancel_promotions  GET      /promotions/cancel/<promotion_id>   end a promotion early

❓ What's Featured in the Project?

The project contains the following:

.github/            - contains a template for github issues
assets/             - contains image files

service/            - service python package
├── static/         - conatains web UI files
├── __init__.py     - package initializer
├── models.py       - module with business models
└── service.py      - module with service routes

tests/              - test cases package
├── __init__.py     - package initializer
├── test_models.py  - test suite for busines models
└── test_service.py - test suite for service routes

.coveragerc         - settings file for code coverage options
.gitignore          - this will ignore vagrant and other metadata files
.travis.yml         - travis configuration file
LICENSE             - Apache 2.0
Procfile            - a command to run by the container
README.md           - repo documentation file
Vagrantfile         - Vagrant file that installs requirements to the VM
codecov.yml         - codecov configuration file
config.py           - configuration parameters
dot-env-example     - copy to .env to use environment variables
manifest.yml        - ibm cloud foundry configuration file
requirements.txt    - list if Python libraries required by your code
runtime.txt         - python version to be used at runtime
setup.cfg           - nosetests configuration file

🔩 Running the Tests

Run the tests using nosetests and coverage

$ nosetests
$ coverage report -m --include=server.py

Nose is configured to automatically include the flags --rednose --with-spec --spec-color --with-coverage so that red-green-refactor is meaningful. If you are in a command shell that supports colors, passing tests will be green while failing tests will be red.

📃 License

Apache 2.0


This repository is part of the NYU class CSCI-GA.2810-001: DevOps and Agile Methodologies taught by John Rofrano, Adjunct Instructor, NYU Curant Institute, Graduate Division, Computer Science.

promotions's People

Contributors

crb618 avatar jc5808 avatar roopgill avatar

Watchers

 avatar

promotions's Issues

Ensure the the command: honcho start works with your Profile

As a Developer
I need a honcho command added to my requirements.txt file
So that I can manage my Procfile-based application

Assumptions:

  • a requirements.txt file is available

Acceptance Criteria:

Given the vagrant VM is up an running
When the "honcho start" command is typed into the command line
Then a working service runs on IBM cloud

Test & Debug Cloud API Functions

As a Developer
I need to debug and test the cloud API functions
So that the API is functioning and accessible

Assumptions:

  • Attempts to interact with the API on the cloud produce errors

Acceptance Criteria:

Given that the functions are working
When we test them from the browser
Then we will be able to successfully perform API functions

Query Promotion BDD Test

As a ... Marketing Manager
I need ... to query the database of promotions
So that ... the promotion can be found.

Assumptions:
*ElephantSQL database is connected to python application

  • there are several promotions available to query from.

Acceptance Criteria:

Given ...a list of promotions are available
When ...I query the list and pick a promotion
Then ...a promotion is returned

Read Promotion BDD Test

As a ... Marketing Manager
I need ... to read a promotion
So that ... the promotion information is visible.

Assumptions:

  • ... ElephantSQL database is connected to python application

Acceptance Criteria:

Given ... a promotion is listed and available
When ... I attempt to view it
Then ... it is viewable

Add a Unit Test Job to the Build Stage of the pipeline

As a developer
I need to add a Unit Test Job to the Build Stage of the pipeline
So that it will run units tests with nosetests

Assumptions:

  • The unit tests will need to run successfully before the project can be deployed to subsequent stages

Acceptance Criteria:

Given the Unit Test Job has been added
When the project is deployed to the build stage
Then it will run units tests

Create UI Page

As a Marketing Manager
I need a simple single UI page
So that I can easily interact with the resource backend

Assumptions:

  • There is not an existing UI page
  • There is an example UI the development team can use as a reference
  • The backend of the resource is fully implemented
  • There is a cloud domain to deploy the resource/UI to

Acceptance Criteria:

Given the UI has been created
When I attempt to interact with the resource
Then I can successfully use the UI to perform actions

Add a Integration Test Stage to Pipeline

As a developer
I need to add an integration stage to the pipeline
So that I can run my integration tests with behave.

Assumptions:

  • Pipeline is built

Acceptance Criteria:

Given I have an integration stage
When I make changes to the master branch
Then integration tests run with behave.

Add Chrome and Selenium to Vagrantfile

As a developer
I need to create BDD tests for my application
So that I know the UI of my application is working as designed.

Assumptions:

  • Selenium is installed in the requirements.txt

Acceptance Criteria:

Given Chrome and Selenium are in my Vagrantfile
When I do vagrant up
And I run my BDD tests
Then I will be able to use Chrome and Selenium

Modify Application for the Database

As a Developer
I need to modify our application to get the database credentials from the VCAP_SERVICES environment
So that the application has access the backend database

Assumptions:

  • We are using Postgres so we will need to initialized a Postgres database connection

Acceptance Criteria:

Given a resource
When requested on the application 
Then resource is displayed

Setup CI with Travis

As a developer
I need to the automate integration testing
So that I can ensure the build is always working or be notified when it is not

Assumptions:

  • There will be multiple developers pushing to a build
  • The tests are can be easily automated

Acceptance Criteria:

Given a developer wants to merge with master
When they are ready to integrate their brand with the master build
Then CI with Travis will automatically re-run tests to ensure all checks pass

Cancel Promotion BDD Test

As a marketing manager
I need to cancel a promotion
So that the promotion is no longer available for customers.

Assumptions:
ElephantSQL database is connected to python application

Acceptance Criteria:

Given there are 4 promotions in the database
When I cancel 1 promotion
Then the are 4 promotions left in the database.

Create prod space in Cloud Foundry

As a developer
I need to create new space in the Cloud Foundry account called 'prod'
So that the project can deploy to the production space if all of the integration tests pass

Assumptions:

  • There is no existing prod space on the account
  • We are also setting up the build, test, and dev spaces

Acceptance Criteria:

Given all of the integration tests pass
When we attempt to deploy to the production space
Then the project will successfully deploy to the prod space

List Promotion BDD Test

As a marketing manager
I need to list of all promotions
So that I can see information on all promotions.

Assumptions:

  • ElephantSQL database is connected to the python application

Acceptance Criteria:

Given 4 promotions exist in the database
When I list all promotions
Then I will see a list of 4 promotions in the database.

Add a Dev Deployment Stage to the Pipeline

As a Developer
I need to add a Dev deployment stage to the pipeline
So that Units tests are deployed to the Dev development stage if they pass

Assumptions:

  • Prod environment is its own environment

Acceptance Criteria:

Given a pull request
When the integration test stage is complete
Then the production deploy stage will automatically trigger the deployment of the new build to production

Update a Promotion in BDD

As a Marketing manager
I need to update a promotion
So that the customer is able to view

Assumptions:

  • ElephantSQL database is connected to python application

Acceptance Criteria:

Given that I have 4 promotions in the database
When I need to update 1
Then I will have 4 promotions in the database with 1 updated

Query Promotion

As a developer
I need to return information about the identified promotion
So that the API user is able view details of the promotion

Assumptions:

  • Information for the specified promotion exists in our database
  • API user is authorized to view information for promotions in our data

Acceptance Criteria:

Given the queried promotion exists
When the API users issues the query
Then the information about the promotion is returned

Create a Production Deploy Stage in Pipelin

As a developer
I need to create a production deploy stage in the pipeline
So that units tests can be deployed to production once they pass

Assumptions:

  • That the production environment is its own environment

Acceptance Criteria:

Given a pull request
When a test stage is done
Then the production deploy stage will automatically deploy a new build to prod

Setup IBM Cloud for the Team

As a developer
I need to create an IBM Cloud account and invite other members of the team to the account
So that team members have access to the application

Assumptions:

  • The team has access to IBM Cloud

Acceptance Criteria:

Given team members have been invited to account
When they try to log in
Then they have access to the project in the cloud

Make Final Code Edits/Updates for Sprint #1

As a developer
I need review to code and sprint goals
So that I can make sure everything for the sprint is complete

Assumptions:

  • The sprint is almost complete

Acceptance Criteria:

Given everything is checked off
When I compare the aspects of the project to the checklist
Then the sprint is complete and the developers can move on to the next sprint

Update Vagrantfile: IBM Cloud CLI

As a developer
I need update the Vagrantfile
So that it downloads and installs the IBM Cloud CLI

Assumptions:

  • There is an example of this is in the lab-bluemix-cf repo

Acceptance Criteria:

Given the Vagrant File contains the necessary updates
When the virtual environment is constructed
Then the IBM Cloud CLI will be downloaded and installed

Make Final Code Edits/Updates for Sprint #2

As a developer
I need review to code and sprint goals
So that I can make sure everything for the sprint is complete

Assumptions:

  • The sprint is almost complete

Acceptance Criteria:

Given everything is checked off
When I compare the aspects of the project to the checklist
Then the sprint is complete and the developers can move on to the next sprint

Connect pipeline to the GitHub repo

As a developer
I need Github to be connected to my CI/CD pipeline
So that when I make changes to my master branch, my service is tested and deployed automatically.

Assumptions:

  • IBM Cloud Pipeline has been set up

Acceptance Criteria:

Given Github is connected to my CI/CD pipeline
When I make changes to the master branch
Then my service will be tested and deployed automatically.

Solve Integration Issue

As a developer
I need to debug the integration stage
So that the team can proceed with implementing the final stage

Assumptions:

  • the integration stage test keeps failing in our delivery pipeline

Acceptance Criteria:

Given the integration stage no longer fails
When we run the job
Then the problem has been solved

Create the Promotion Model

As a Marketing Manager
I need to have promotion data persistent in a database
So that it can be saved and edited by other managers

Assumptions:

  • Promotions will have the following attributes:
    -- Name
    -- Description
    -- Start Date
    -- End Date

Acceptance Criteria:

Given there is no model
When the model is completed
Then there will be a table in the data

Read Promotion

As a marketing manager
I need a user who is interacting with our API to be able to read our promotions
So that they are able to integrate them for their individual use.

Assumptions:

  • The API has been built
  • The API can be called and be integrated

Acceptance Criteria:
Given the API is functioning
When a User calls the API
Then the promotions are visible and able to be integrated

Create a Continuous Delivery Pipeline in IBM Cloud

As a developer
I need a continuous delivery pipeline in IBM Cloud
So that when I make changes to my master branch they are automatically tested and pushed to the cloud.

Assumptions:

  • IBM Cloud is connected to Github

Acceptance Criteria:

Given I have a continuous delivery pipeline
When I make changes to my master branch in Github
Then my service will be automatically tested and deployed to the cloud.

Delete Promotion

As a marketing manager
I need to have the ability to delete promotions
So that end users no longer see expired promotions/offers/campaigns.

Assumptions:

  • Deleted promotions will no longer be viewable by end users
  • Deleted promotions will be stored in the database so further analysis can be done

Acceptance Criteria:
Given a promotion is deleted
When I delete the promotion
And I go to the user interface, it is no longer available
And it is stored in the database
Then the promotion is deleted.

Add Delivery Pipeline to CI/CD pipeline in IBM Cloud

As a developer
I need a Delivery Pipeline in IBM Cloud
So that I can create Build, Dev, Test, Prod sequence.

Assumptions:

  • I have set up an IBM Cloud Toolchain to build off of
  • I have connected Github to IBM Cloud

Acceptance Criteria:

Given I have enabled Delivery Pipeline
When I created a Build Stage in my CI/CD pipeline
Then my changes to master in Github will go through the Build stage and nosetests will run.

Setup Local Vagrant Development Environment

As a Developer
I need my local development environment to use a Vagrantfile (VM)
So that I can write code in the same environment as my team

Assumptions:

  • Use Vagrant and VirtualBox to build a local dev environment
  • Python will be used for development

Acceptance Criteria:*
When I issue git clone on the project
And I change into the project folder
And I issue vagrant up
Then I should have a complete development environment on my workstation

List All Promotions

As a marketing manager
I need to see a list of all promotions
So that I can understand the status and effectiveness of all promotions/offers/campaigns.

Assumptions:

  • List will show ALL promotions (historical, current, future) therefore a status should be included
  • Promotions will be stored in the database

Acceptance Criteria:
Given a list of all promotions
When I query the promotions table
Then the promotions list function works.

Cancel Promotion

As a Marketing Manager
I need to cancel a promotion
So that it is no longer active

Assumptions:

  • There is a promotion currently active that I want to end early
    *Developers have provided functions that make it possible to find the promotion, set it's end date to now, and save it

Acceptance Criteria:

Given that I make a request to cancel a promotion
When I would like to end a promotion early
Then the promotion is canceled (It's end date becomes 'now')

Update ReadMe

As a resource API user
I need to view readme with instructions on what calls are available, what inputs they expect, and how to run and test the code
So that I know how it works

Assumptions:

  • We (the development team) have defined what calls are available
  • The Github is publicly available

Acceptance Criteria:

Given user views the ReadMe
When they are ready to use are resource
Then readme contains the necessary information

Create a promotion in BDD

As a Marketing manager
I need to Create a promotion
So that our customers are able to access a new promotion

Assumptions:

  • ElephantSQL database is connected to python application

Acceptance Criteria:

Given that there are 3 promotions in the database 
When I add 1 more new promotion
Then there are 4 promotions in the database

Update Promotion

As a marketing manager
I need to update a current running promotion
So that a customer can use the correct promotion

Assumptions:

  • That the promotion will automatically be updated in all VM
  • Users are aware that promotions will be updated

Acceptance Criteria:
Given a promotion is updated
When a new time, date or price is updated
Then the promotion should be published

Delete Promotion BDD Test

As a marketing manager
I need to delete a promotion
So that the promotion is no longer in the database.

Assumptions:

  • ElephantSQL database is connected to python application

Acceptance Criteria:

Given there are 4 promotions in the database
When I delete 1 promotion
Then the are 3 promotions in the database.

Import Project Template

As a developer
I need the project template to be available the repo
So that I can pull from master and have all necessary files (vagrantfile, gitignore, etc.)

Assumptions:

  • We (the developers) each have access to the project repo
  • We have created local repos and are ready to pull from the master branch

Acceptance Criteria:

Given the project template is pulled to my local machine
When I pull from the master branch
Then the project template has been imported to our repo

Create a Python Flask Cloud Foundry Application

As a developer
I need to create a Python Flask Cloud Foundry application in IBM Cloud
So that the application registered and can be deployed.

Assumptions:

  • The naming convention will use the singular version of the resource name prefixed by nyu- and suffixed by -service-s20 (i.e. promotion)

Acceptance Criteria:

Given python flask application has been created
When we attempt to deploy the project
Then it will successfully link to the cloud

Provision ElephantSQL dB Instance

As a developer
I need to create and provision a postgresql database instance for the cloud
So that it can be connected to the IBM Cloud Project

Assumptions:

  • Our project will need a PostgreSQL database

Acceptance Criteria:

Given the elephantsql db has been provisioned
When we attempt to create a connection between the dB to our app
Then the connection will be made successfully

Create a BDD .feature file and steps.py

As a Developer
I need a BDD .feature file and .py file
So that my restful APIs can be tested from the outside in.

Assumptions:

  • BDD .feature file and .py files are available

Acceptance Criteria:

Given I have a RESTful API
When tested
Then the API runs as intended.

Perform Promotion Action

As a marketing manager
I need to perform a promotion action
So that I am able to perform the desired action

Assumptions:

  • Our team has identified this action
  • The functions/steps needed to perform this action have been created by developers

Acceptance Criteria:

Given the action is defined, developed, and tested
When the user attempts to perform the action
Then the action is successfully performed

Add a Build Stage to the Pipeline

As a developer
I need a build stage in my pipeline
So that tests run automatically.

Assumptions:

  • IBM Cloud toolchain is created
  • Github is connected to toolchain
  • Delivery Pipeline has been enabled within the Toolchain

Acceptance Criteria:

Given I have a build stage in my pipeline
When I make changes to my master branch in Github
Then nosetests will run automatically.

Connect ElephantSQL Database to Python App within IBMCloud

As a Developer
I need the SQL Database to be available within IBM cloud
So that the Python app is able to store data

Assumptions:

  • Elephant SQL database is set up

Acceptance Criteria:

Given ... a team member opens ibm cloud
When ... the dashboard is opened
Then ... we can see the Python app and elephantSQL connection in the dashboard

Identify Action

As a developer
I need to identify a useful action for the promotions resource
So that the action can be performed by the authorized user of our API

Assumptions:

  • the action requires multiple steps to be completed
  • the action is not list, update, create, read, or delete

Acceptance Criteria:

Given the action is identified
When we begin development on the action item
Then we can build the action alongside other API functions

Update ReadMe with New Developments

As a resource API user
I need to view readme document with up-to-date information on the project
So that I know how it works

Assumptions:

  • We (the development team) have defined what calls are available
  • The Github is publicly available
  • The readme is not currently up to date

Acceptance Criteria:

Given user views the ReadMe
When they are ready to use are resource
Then readme contains the necessary information

Create Promotion

As a Marketing Manager
I need to create a Promotion
So that users can see discounts presented on the site

Assumptions:

  • promotions are agreed upon by the marketing team

Acceptance Criteria:

Given a release of a promotion
Then users see offers for the product 

Push Application to IBM Cloud

As a developer
I need to push my application to the IBM Cloud
So that my application runs on the IBM Cloud.

Assumptions:

  • Our team has an IBM account and everyone has access

Acceptance Criteria:

Given I want to run my application in the cloud
When I hit ibmcloud cf push
Then my application is in the IBM Cloud.

Create Cloud Foundry Metadata Files

As a developer
I need to create the necessary Cloud Foundry metadata files for deployment
So that IBM Cloud will know how to deploy the application

Assumptions:

  • The necessary files are manifest.yml, Procfile, runtime.txt

Acceptance Criteria:

Given the Cloud Foundry metadata files have been created
When we attempt to deploy the project
Then it will be successfully deployed

Fix date time format and id in all files

As a developer
I need the date time and ids formatted properly
So that I can run all my BDD tests.

Assumptions:

  • Packages for BDD tests are installed.

Acceptance Criteria:

Given date time and ids are formatted correctly throughout my files
When I run my BDD tests
Then all tests should pass.

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.