Exemplo n.º 1
0
class TestAddIngredientToCreation():  #US2
    def setup_method(self):
        self.burger = Burger()
        self.wrap = Wrap()
        self.ing_w_limit = Ingredient("Patty", 5, 10, 2)
        self.ing_wout_limit = Ingredient("Cheese", 5, 10)

    def test_add_ingredient_under_lim(self):
        self.wrap.add_ingredient(self.ing_wout_limit, 1)
        assert len(self.wrap.ingredients) == 1
        assert self.wrap.ingredients[self.ing_wout_limit] == 1
        assert self.ing_wout_limit in self.wrap.ingredients

    def test_add_ingredient_on_limit(self):
        self.burger.add_ingredient(self.ing_w_limit, 2)
        assert len(self.burger.ingredients) == 1
        assert self.burger.ingredients[self.ing_w_limit] == 2
        assert self.ing_w_limit in self.burger.ingredients

    def test_add_ingredient_over_limit(self):
        with pytest.raises(LimitError):
            self.burger.add_ingredient(self.ing_w_limit, 10)

    def test_add_ingredient_over_quantity(self):
        with pytest.raises(QuantityError):
            self.wrap.add_ingredient(self.ing_wout_limit, 20)
Exemplo n.º 2
0
 def test_add_multiple_creations(self):
     creation1 = Burger()
     creation2 = Wrap()
     self.order.add_creation(creation1)
     self.order.add_creation(creation2)
     assert len(self.order.creations) == 2
     assert creation1 in self.order.creations
     assert creation2 in self.order.creations
Exemplo n.º 3
0
 def test_many_ingredients(self):
     i1 = Ingredient("Patty", 5, 10)
     i2 = Ingredient("Cheese", 1, 10)
     i3 = Ingredient("Carrot", 1.5, 10)
     i4 = Ingredient("Lettuce", 0.5, 10)
     burger = Burger()
     burger.add_ingredient(i1, 2)  #10
     burger.add_ingredient(i2, 1)  #1
     burger.add_ingredient(i3, 3)  #4.5
     burger.add_ingredient(i4, 2)  #1.0
     assert burger.cost() == 18.5  #total 16.5 plus base cost 2$
Exemplo n.º 4
0
 def setup_method(self):
     self.order = Order(1)
     self.order.add_side(Side("Fries", 1, 10), 1)
     self.order.add_side(Side("Cake", 3, 10), 2)
     self.order.add_drink(Drink("Juice", 3, 10), 2)
     self.order.add_drink(Drink("Soda", 3, 10), 1)
     burger = Burger()
     burger.add_ingredient(Ingredient("Patty", 1, 10), 1)
     burger.add_ingredient(Ingredient("Cheese", 1, 10), 2)
     self.order.add_creation(burger)
Exemplo n.º 5
0
def setup_burger():
    i1 = Ingredient("Patty", 5, 10)
    i2 = Ingredient("Cheese", 1, 10)
    i3 = Ingredient("Carrot", 1.5, 10)
    i4 = Ingredient("Lettuce", 0.5, 10)
    burger = Burger()
    burger.add_ingredient(i1, 2)  #10
    burger.add_ingredient(i2, 1)  #1
    burger.add_ingredient(i3, 3)  #4.5
    burger.add_ingredient(i4, 2)  #1.0
    return burger
Exemplo n.º 6
0
def setup_order():
    order = Order(1)
    order.add_side(Side("Fries", 1, 10), 1)
    order.add_side(Side("Cake", 3, 10), 2)
    order.add_drink(Drink("Juice", 3, 10), 2)
    order.add_drink(Drink("Soda", 3, 10), 1)
    burger = Burger()
    burger.add_ingredient(Ingredient("Patty", 1, 10), 1)
    burger.add_ingredient(Ingredient("Cheese", 1, 10), 2)
    order.add_creation(burger)
    return order
Exemplo n.º 7
0
def setup_system():
    sys = Management_System()

    #Set up Inventory
    sys.inventory.add_drink("Juice", 1, 10)
    sys.inventory.add_drink("Soda", 1, 10)
    sys.inventory.add_drink("Water", 1, 10)

    sys.inventory.add_ingredient("Patty", 1, 11)
    sys.inventory.add_ingredient("Falafel", 1, 11)
    sys.inventory.add_ingredient("Cheese", 1, 11)
    sys.inventory.add_ingredient("Tomato", 1, 11)
    sys.inventory.add_ingredient("Carrot", 1, 11)
    sys.inventory.add_ingredient("Lettuce", 1, 11)
    sys.inventory.add_ingredient("Chilli", 1, 11)

    sys.inventory.add_side("Fruit", 1, 11)
    sys.inventory.add_side("Fries", 1, 11)
    sys.inventory.add_side("Cake", 1, 11)

    #Add Orders
    sys.add_order()
    sys.add_order()
    sys.add_order()
    sys.add_order()

    #Set up Order details
    o1 = sys.current_orders[0]
    o2 = sys.current_orders[1]
    o3 = sys.current_orders[2]
    o4 = sys.current_orders[3]

    o1.add_side(sys.inventory.sides[0], 2)
    o1.add_drink(sys.inventory.drinks[0], 1)
    o1.add_creation(Burger())
    o1.creations[0].add_ingredient(sys.inventory.ingredients[0], 2)
    o1.creations[0].add_ingredient(sys.inventory.ingredients[3], 1)
    o1.creations[0].add_ingredient(sys.inventory.ingredients[5], 1)

    o2.add_side(sys.inventory.sides[1], 1)
    o2.add_drink(sys.inventory.drinks[1], 1)
    o2.add_creation(Wrap())
    o2.creations[0].add_ingredient(sys.inventory.ingredients[2], 1)
    o2.creations[0].add_ingredient(sys.inventory.ingredients[1], 2)
    o2.creations[0].add_ingredient(sys.inventory.ingredients[5], 1)

    o3.add_side(sys.inventory.sides[0], 2)
    o3.add_drink(sys.inventory.drinks[0], 1)
    o3.add_creation(Burger())
    o3.creations[0].add_ingredient(sys.inventory.ingredients[0], 2)
    o3.creations[0].add_ingredient(sys.inventory.ingredients[4], 1)
    o3.creations[0].add_ingredient(sys.inventory.ingredients[6], 1)

    o4.add_side(sys.inventory.sides[0], 2)
    o4.add_drink(sys.inventory.drinks[0], 1)
    o4.add_creation(Burger())
    o4.creations[0].add_ingredient(sys.inventory.ingredients[0], 2)
    o4.creations[0].add_ingredient(sys.inventory.ingredients[2], 1)
    o4.creations[0].add_ingredient(sys.inventory.ingredients[3], 1)

    return sys
Exemplo n.º 8
0
def test_setup():
    burger = Burger()
    assert len(burger.ingredients) == 0

    wrap = Wrap()
    assert len(wrap.ingredients) == 0
Exemplo n.º 9
0
 def test_burger_with_ingredient(self):
     burger = Burger()
     burger.add_ingredient(Ingredient("Patty", 3, 10), 2)
     assert burger.cost() == 8
Exemplo n.º 10
0
 def test_empty_burger(self):
     burger = Burger()
     assert burger.cost() == 2
Exemplo n.º 11
0
 def setup_method(self):
     self.burger = Burger()
     self.wrap = Wrap()
     self.ing_w_limit = Ingredient("Patty", 5, 10, 2)
     self.ing_wout_limit = Ingredient("Cheese", 5, 10)
Exemplo n.º 12
0
 def test_add_creation(self):
     new_creation = Burger()
     self.order.add_creation(new_creation)
     assert len(self.order.creations) == 1
     assert self.order.creations[0] == new_creation
Exemplo n.º 13
0
 def create_creation(self):
     creation = Burger() if self.type == "Burger" else Wrap()
     for k, v in self.ingredients.items():
         ing = self.inv.get_ing(k)
         creation.add_ingredient(ing, int(v))
     return creation