Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#160233942 Add feature to update food order status #4

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
42bd80b
[Feature #160231913] Add function stubs to fetch all orders
artorious Sep 4, 2018
6fa614d
[Feature #160231913] Add failing tests to fetch all orders
artorious Sep 4, 2018
3944718
[Feature #160232168] Build code to pass unit tests to FETCH ALL ORDERS
artorious Sep 4, 2018
52e0f38
[chore #160260660] Add test coverage
artorious Sep 4, 2018
d0a7499
[chore #160260660] update travis.yml
artorious Sep 4, 2018
bf95e28
[chore #160260660] Add readme badges
artorious Sep 4, 2018
3f01b7e
[chore #160260660] update travis.yml
artorious Sep 4, 2018
ed97309
[chore #160260660] Update readme
artorious Sep 4, 2018
8970416
[Chore #160260660] install coveralls locally
artorious Sep 5, 2018
c47083a
[Feature #160231913] update tests for mode
artorious Sep 5, 2018
2ba9fa6
[chore #160260660] Specify scripts to cover in tests
artorious Sep 5, 2018
6c6fc76
[chore #160260660] Specify scripts to cover in tests
artorious Sep 5, 2018
fc923f9
Merge branch 'ft-fetch-all-orders-160231913' of https://github.com/ar…
artorious Sep 5, 2018
3a592dc
[chore #160260660] Finalize test coverage and badges.
artorious Sep 5, 2018
de6fdbd
[Feature #160233616] Add failing tests to place new order
artorious Sep 5, 2018
4ad86a8
[Feature #160233817] Build code to pass unit tests to place a new order
artorious Sep 5, 2018
e2ad1c6
[chore #160233914] Test on postman
artorious Sep 5, 2018
974249a
[Feature #160233817] Add datetime and accept status to new food orders
artorious Sep 6, 2018
11260b0
[Feature #160233117] Add function stubs fetching a food order by ID
artorious Sep 6, 2018
b1e515d
[Feature #160233117] Add Failing tests
artorious Sep 6, 2018
98d1ee3
[Feature #160233247] Build code to pass tests
artorious Sep 6, 2018
8fc2b39
[feature #160233942] Add failling tests to update an order
artorious Sep 7, 2018
18cb10a
[Feature #160234323] Build out code to pass tests
artorious Sep 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

#. VsCode stuff
.vscode/
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

language: python
python:
- "3.6"

# Command to install dependancies
install: "make"

# command to run tests
script:
- coverage run -m pytest
after_success:
- coveralls
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
init:
pip install pipenv --upgrade
pipenv install --dev
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pytest = "*"
pytest-cache = "*"
"pytest-pep8" = "*"
flask = "*"
coverage = "*"
coveralls = "*"

[dev-packages]

Expand Down
88 changes: 87 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[![Build Status](https://travis-ci.com/artorious/speedy_chakula_app.svg?branch=ft-fetch-all-orders-160231913)](https://travis-ci.com/artorious/speedy_chakula_app) [![Coverage Status](https://coveralls.io/repos/github/artorious/speedy_chakula_app/badge.svg?branch=ft-fetch-all-orders-160231913)](https://coveralls.io/github/artorious/speedy_chakula_app?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability)](https://codeclimate.com/github/codeclimate/codeclimate/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/test_coverage)](https://codeclimate.com/github/codeclimate/codeclimate/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# speedy_chakula_app
A fast-Food-Fast is a food delivery service app for a restaurant

# Features
* Retrieve and display all food orders
* Place a new food order
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
from app import views

# Load the config file
app.config.from_object('config')
app.config.from_object('config')
82 changes: 82 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -1 +1,83 @@
""" Data representation - holds routines for user to interact with the API."""

import datetime


class FoodOrders():
""" Holds methods for food orders

Attributes:
all_food_orders (dict) - Variable holds all food orders
{order_count(int):
{'orderid': int,
'username': str,
'order_qty': int,
'order_description': str,
'order_datetime': str,
'order_accept_status': bool
}
}
"""

def __init__(self):
self.all_food_orders = {}
self.food_order_count = 1

def fetch_all_food_orders(self):
""" (FoodOrders) -> dict

Fetches all food orders. Returns a dict.
"""
return self.all_food_orders

def place_new_order(self, order_request_info):
""" (FoodOrders, dict) -> dict

Creates a new food order with provided <order_info>.
Returns message to user on creation or failure
"""
if isinstance(order_request_info, dict):
order_request_info['order_datetime'] = \
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
order_request_info['order_accept_status'] = False
self.all_food_orders[self.food_order_count] = order_request_info
self.food_order_count += 1

return {"Order placement message": "Order succesfully placed"}
else:
raise TypeError("Argument should be a dictionary")

def fetch_order_by_id(self, orderid):
""" (FoodOrders, int) -> dict

Returns food order with corresponding orderid
"""
try:
int(orderid)
if orderid in self.all_food_orders:
return self.all_food_orders[orderid]
else:
return {"Order fetching error message": "orderid out of range"}
except ValueError:
return {
"Order fetching error message": "orderid should be integer"
}

def update_order_by_id(self, orderid, update_status):
""" (FoodOrders, int, bool) -> dict

Returns custom message to user to indicat update status
"""
if isinstance(orderid, int) and isinstance(update_status, bool):
if orderid in self.all_food_orders:
self.all_food_orders[orderid]['order_accept_status'] =\
update_status
return {"Order update message": "Update Successful"}
return {"Order update error message": "orderid out of range"}
return {
"Order update error message": "Invalid Input"
}


if __name__ == '__main__':
FoodOrders()
Loading