def test_getMenu(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) menu = pizza.get_menu() self.assertEqual( menu, { "drinks": { "Coke": 2.5, "Diet Coke": 3, "Coke Zero": 3, "Pepsi": 2.5, "Diet Pepsi": 3, "Dr. Pepper": 4, "Water": 1, "Juice": 2 }, "pizza": { "Type": { "pepperoni": [["olives", "tomatoes"], 10, 15, 20], "margherita": [["olives", "tomatoes"], 11, 15, 20], "vegetarian": [["olives", "tomatoes"], 10, 15, 20], "Neapolitan": [["olives", "tomatoes"], 10, 15, 20], "custom": [[], 5, 10, 15] }, "Toppings": { "olives": 2, "tomatoes": 2, "mushrooms": 1.5, "jalapenos": 2, "chicken": 5, "beef": 6, "pepperoni": 6 } } })
def test_orderTotalcost(self): drink = DrinkFactory.creat_item("Coke", 1) pizza = PizzaFactory.create_item("pepperoni", 12, 2) order = Order(1) order.add_item(drink) order.add_item(pizza) self.assertEqual(order.get_total_price(), 22.5)
def test_submit_order(self): drink = DrinkFactory.creat_item("Coke", 1) pizza = PizzaFactory.create_item("pepperoni", 12, 2) order = Order(1) order.add_item(drink) order.add_item(pizza) self.assertEqual(submit_order(order), 200)
def init_item_to_be_updated(item): if item["category"] == "Pizza": new_item = PizzaFactory.create_item(item["type"], item["size"], item["quantity"]) new_item.change_topping(item["topping"]) else: new_item = DrinkFactory.creat_item(item["type"], item["quantity"]) return new_item
def test_addItem(self): drink = DrinkFactory.creat_item("Coke", 1) pizza = PizzaFactory.create_item("pepperoni", 12, 2) order = Order(1) order.add_item(drink) order.add_item(pizza) self.assertEqual(order.get_items()[0].__dict__, { "type": "Coke", "price": 2.5, "quantity": 1, "category": "Drink" }) self.assertEqual( order.get_items()[1].__dict__, { "type": "pepperoni", "price": 20, "quantity": 2, "category": "Pizza", "size": 12, "topping": ['olives', 'tomatoes'], })
def test_pizzaGetQuantity(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) self.assertEqual(pizza.get_quantity(), 1)
def test_addOneTopping(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) pizza.add_toppings(["olives"]) self.assertEqual(pizza.get_topping(), ["olives", "tomatoes", "olives"]) self.assertEqual(pizza.get_price(), 12.0)
def test_pizzaChangeToppingMultipleQuantity(self): pizza = PizzaFactory.create_item("pepperoni", 12, 2) pizza.change_topping(["olives"]) self.assertEqual(pizza.get_topping(), ["olives"]) self.assertEqual(pizza.get_price(), 16)
def test_addMultipleToppingAndMultipleQuantity(self): pizza = PizzaFactory.create_item("pepperoni", 12, 2) pizza.add_toppings(["olives", "mushrooms"]) self.assertEqual(pizza.get_topping(), ["olives", "tomatoes", "olives", "mushrooms"]) self.assertEqual(pizza.get_price(), 27.0)
def test_pizzaChangeToMoreTopping(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) pizza.change_topping(["olives", "tomatoes", "chicken"]) self.assertEqual(pizza.get_topping(), ["olives", "tomatoes", "chicken"]) self.assertEqual(pizza.get_price(), 15)
def test_pizzaChangeQuantity(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) pizza.change_quantity(3) self.assertEqual((pizza.get_price()), 30)
def test_initMultipleQuantity(self): pizza = PizzaFactory.create_item("pepperoni", 12, 2) self.assertEqual(pizza.get_price(), 20) self.assertEqual(pizza.get_size(), 12) self.assertEqual(pizza.get_type(), "pepperoni") self.assertEqual(pizza.get_quantity(), 2)
def test_pizzaChangeToLessTopping(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) pizza.change_topping(["olives"]) self.assertEqual(pizza.get_topping(), ["olives"]) self.assertEqual(pizza.get_price(), 8)
def test_pizzaGetTopping(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) self.assertEqual(pizza.get_topping(), ["olives", "tomatoes"])
def setup_pizza(): pizza = setup_pizza_type() size = setup_pizza_size() newItem = PizzaFactory.create_item(pizza, int(size), 1) return newItem
def test_pizzaChangeTypeMultipleQuantity(self): pizza = PizzaFactory.create_item("pepperoni", 12, 2) pizza.change_type("margherita") self.assertEqual(pizza.get_type(), "margherita") self.assertEqual(pizza.get_topping(), ["olives", "tomatoes"]) self.assertEqual(pizza.get_price(), 21)
def test_LargepizzaChangeType(self): pizza = PizzaFactory.create_item("pepperoni", 18, 1) pizza.change_type("margherita") self.assertEqual(pizza.get_type(), "margherita") self.assertEqual(pizza.get_topping(), ["olives", "tomatoes"]) self.assertEqual(pizza.get_price(), 20)
def test_pizzachangeSizeMultipleQuantity(self): pizza = PizzaFactory.create_item("pepperoni", 12, 2) pizza.change_size(15) self.assertEqual(pizza.get_size(), 15) self.assertEqual(pizza.get_price(), 30)
def test_pizzachangeSizeToLarge(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) pizza.change_size(18) self.assertEqual(pizza.get_size(), 18) self.assertEqual(pizza.get_price(), 20)
def test_pizzachangeSizeToSmall(self): pizza = PizzaFactory.create_item("pepperoni", 15, 1) pizza.change_size(12) self.assertEqual(pizza.get_size(), 12) self.assertEqual(pizza.get_price(), 10)
def test_pizzaGetSiza(self): pizza = PizzaFactory.create_item("pepperoni", 12, 1) self.assertEqual(pizza.get_size(), 12)
def test_initLargePizza(self): pizza = PizzaFactory.create_item("pepperoni", 18, 1) self.assertEqual(pizza.get_price(), 20) self.assertEqual(pizza.get_size(), 18) self.assertEqual(pizza.get_type(), "pepperoni") self.assertEqual(pizza.get_quantity(), 1)