Esempio 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)
Esempio n. 2
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)
Esempio n. 3
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
Esempio n. 4
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$
Esempio n. 5
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
Esempio n. 6
0
 def test_burger_with_ingredient(self):
     burger = Burger()
     burger.add_ingredient(Ingredient("Patty", 3, 10), 2)
     assert burger.cost() == 8
Esempio n. 7
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