def test_update_total(self): order = Order(1) assert order.order_total == 0 pizza = Pizza("vegetarian_pizza", 0, "small") order.add_item(pizza) order.update_total() assert order.order_total == 9.99
def test_remove_item(self): order = Order(1) pizza = Pizza("vegetarian_pizza", 0, "small") order.add_item(pizza) order.remove_item(1) assert 1 not in order.ids_to_items assert len(order.items) == 0
def test_add_item(self): order = Order(1) pizza = Pizza("vegetarian_pizza", 0, "small") order.add_item(pizza) assert pizza.id == 1 assert 1 in order.ids_to_items assert order.ids_to_items[1] == pizza assert len(order.items) == 1
print("print item 3 ", a3.print_item()) print("\nbase price 1 = ", a1.get_item_base_price()) print("GST 1 = ", a1.calculate_gst()) print("PST 1 = ", a1.calculate_qst()) print("\nbase price 2 = ", a2.get_item_base_price()) print("GST 2 = ", a2.calculate_gst()) print("PST 2 = ", a2.calculate_qst()) print("\nTotal 1 = ", a1.get_item_total()) print("\nTotal 2 = ", a2.get_item_total()) print("\nTotal 3 = ", a3.get_item_total()) new_order1 = Order() new_order2 = Order() new_order3 = Order() new_order1.add_item(a1) # adding the first item to the first order new_order2.add_item(a1) # adding the first item to the second order new_order2.add_item(a2) # adding the second item to the second order new_order3.add_item(a3) # adding the third item to the third order print("\nOrder 1 summary printed: ", new_order1.print_order_summary()) new_order2.remove_item( 12345678) # removing the first item from the second order print("\nOrder 2 summary printed: ", new_order2.print_order_summary()) print("\nOrder 3 summary printed: ", new_order3.print_order_summary()) for order in range(100): new_order = Order() new_order.add_item(a1) # adding the first item to the new order new_order.add_item(a2) # adding the second item to the new order new_order.add_item(a3) # adding the third item to the new order
def test_update_item_toppings(self): order = Order(1) pizza = Pizza("pepperoni_pizza", 0, "small") order.add_item(pizza) order.update_item(1, "toppings", ["olives"], "add") assert pizza.toppings == {"pepperoni": 1, "tomatoes": 1, "olives": 1}
def test_update_item_size(self): order = Order(1) pizza = Pizza("pepperoni_pizza", 0, "small") order.add_item(pizza) order.update_item(1, "size", "medium") assert pizza.size == "medium"
def test_update_item_type(self): order = Order(1) pizza = Pizza("pepperoni_pizza", 0, "small") order.add_item(pizza) order.update_item(1, "type", "vegetarian_pizza") assert pizza.get_type() == "vegetarian_pizza"
def test_get_toppings(self): order = Order(1) pizza = Pizza("pepperoni_pizza", 0, "small") order.add_item(pizza) order.get_toppings(1) == {"pepperoni": 1, "tomatoes": 1}
def test_is_pizza(self): order = Order(1) pizza = Pizza("vegetarian_pizza", 0, "small") order.add_item(pizza) assert order.is_pizza(1) == "True"
def test_get_item_by_id(self): order = Order(1) pizza = Pizza("vegetarian_pizza", 0, "small") order.add_item(pizza) assert order.get_item_by_id(1) != "None"
from Item import Item from Order import Order Od = Order() while True: sk = str(input("What is the sku of the item to add?")) na = str(input("What is the name of the item to add?")) co = float(input("How much does the item cost?")) while True: tx = str(input("Is the item taxable? (Y/N)")) if tx == "y" or tx == "Y": tx = True break elif tx == "n" or tx == "N": tx = False break else: print ("y or n please!") It = Item(sk, na, co, tx) Od.add_item(It) yn = str(input("Add another item? (Y/N)")) if yn == "n" or yn == "N": break Od.generate_receipt(36)
) while True: is_taxable = input("Is this item taxable? (Y/N) >> ").upper() if is_taxable == "Y": taxable = True break elif is_taxable == "N": taxable = False break else: print("Your input is not valid, please, try again.") new_item = Item(sku, name, price, taxable) users_new_order.add_item(new_item) elif answer_string == "DEL": print(users_new_order.print_order_summary()) sku_to_delete = int( input("Please, enter the SKU of item you want to delete >> ")) users_new_order.remove_item(sku_to_delete) print(users_new_order.print_order_summary()) elif answer_string == "FIN": print(users_new_order.print_order_summary()) else: print( "It seams that you've chosen non-existent option. Please, try again." )