Exemplo n.º 1
0
 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
                 }
             }
         })
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
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
Exemplo n.º 5
0
 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'],
         })
Exemplo n.º 6
0
 def test_pizzaGetQuantity(self):
     pizza = PizzaFactory.create_item("pepperoni", 12, 1)
     self.assertEqual(pizza.get_quantity(), 1)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
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)
Exemplo n.º 11
0
 def test_pizzaChangeQuantity(self):
     pizza = PizzaFactory.create_item("pepperoni", 12, 1)
     pizza.change_quantity(3)
     self.assertEqual((pizza.get_price()), 30)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 def test_pizzaGetTopping(self):
     pizza = PizzaFactory.create_item("pepperoni", 12, 1)
     self.assertEqual(pizza.get_topping(), ["olives", "tomatoes"])
Exemplo n.º 15
0
def setup_pizza():
    pizza = setup_pizza_type()
    size = setup_pizza_size()
    newItem = PizzaFactory.create_item(pizza, int(size), 1)
    return newItem
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 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)
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
 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)
Exemplo n.º 20
0
 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)
Exemplo n.º 21
0
 def test_pizzaGetSiza(self):
     pizza = PizzaFactory.create_item("pepperoni", 12, 1)
     self.assertEqual(pizza.get_size(), 12)
Exemplo n.º 22
0
 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)