def test_wrap(self): i1 = Ingredient("Falafel", 5, 10) i2 = Ingredient("Cheese", 1, 10) wrap = Standard_Wrap(4) assert (wrap.cost() == 4) # check original cost is assigned wrap.add_ingredient(i1, 2) wrap.add_ingredient(i2, 1) assert (wrap.cost() == 4) # check cost unchanged by adding ingredients
def test_burger(self): i1 = Ingredient("Patty", 5, 10) i2 = Ingredient("Cheese", 1, 10) burger = Standard_Burger(5) assert (burger.cost() == 5) # check original cost is assigned burger.add_ingredient(i1, 1) burger.add_ingredient(i2, 1) assert (burger.cost() == 5 ) # check cost unchanged by adding ingredients
class TestCalculateCostItem(): def setup_method(self): self.ingredient = Ingredient("Cheese", 5, 10) def test_calculate_cost_successful(self): assert self.ingredient.calculate_cost(2) == 10 def test_calculate_cost_negative(self): with pytest.raises(ValueError): self.ingredient.calculate_cost(-2)
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)
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$
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
def setup_standard_wrap(): i1 = Ingredient("Falafel", 5, 10) i2 = Ingredient("Cheese", 1, 10) i3 = Ingredient("Carrot", 1.5, 10) i4 = Ingredient("Lettuce", 0.5, 10) wrap = Standard_Wrap(5) wrap.add_ingredient(i1, 2) wrap.add_ingredient(i2, 1) wrap.add_ingredient(i3, 3) wrap.add_ingredient(i4, 2) return wrap
def setup_wrap(): i1 = Ingredient("Falafel", 5, 10) i2 = Ingredient("Cheese", 1, 10) i3 = Ingredient("Carrot", 1.5, 10) i4 = Ingredient("Lettuce", 0.5, 10) wrap = Wrap() wrap.add_ingredient(i1, 2) #10 wrap.add_ingredient(i2, 1) #1 wrap.add_ingredient(i3, 3) #4.5 wrap.add_ingredient(i4, 2) #1.0 return wrap
def setup_standard_burger(): i1 = Ingredient("Patty", 5, 10) i2 = Ingredient("Cheese", 1, 10) i3 = Ingredient("Carrot", 1.5, 10) i4 = Ingredient("Lettuce", 0.5, 10) burger = Standard_Burger(5) burger.add_ingredient(i1, 2) burger.add_ingredient(i2, 1) burger.add_ingredient(i3, 3) burger.add_ingredient(i4, 2) return burger
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
class TestItemQuantityUpdate(): def setup_method(self): self.ing1 = Ingredient("Cheese", 5, 40) self.side1 = Side("Wedges", 2, 50) self.drink1 = Drink("Cola", 3, 50) def test_add_to_item(self): self.ing1.update_quantity(10) assert self.ing1.total_quantity == 50 self.side1.update_quantity(10) assert self.side1.total_quantity == 60 self.drink1.update_quantity(10) assert self.drink1.total_quantity == 60
class TestUpdateQuantity(): def setup_method(self): self.ing1 = Ingredient("Cheese", 5, 40) self.side1 = Side("Wedges", 2, 50) self.drink1 = Drink("Cola", 3, 50) def test_subtract_from_item(self): self.ing1.update_quantity(-10) self.side1.update_quantity(-10) self.drink1.update_quantity(-10) assert self.ing1.total_quantity == 30 assert self.side1.total_quantity == 40 assert self.drink1.total_quantity == 40 def test_subtract_too_much_from_item(self): with pytest.raises(QuantityError): self.ing1.update_quantity(-70) self.side1.update_quantity(-70) self.drink1.update_quantity(-70)
def setup_method(self): self.ing1 = Ingredient("Cheese", 5, 40) self.side1 = Side("Wedges", 2, 50) self.drink1 = Drink("Cola", 3, 50)
def test_ing_setup_no_limit(): i = Ingredient("Cheese", 4, 1) assert i.name == "Cheese" assert i.price == 4 assert i.total_quantity == 1 assert i.limit == None
def test_ing_setup_with_limit(): i = Ingredient("Cheese", 4, 1, 10) assert i.limit == 10
def test_add_side_over_limit(self): new_side = Side("Fries", 1, 10, 2) with pytest.raises(LimitError): self.order.add_side(new_side, 3) def test_add_drink_over_limit(self): new_drink = Drink("Juice", 1, 10, 2) with pytest.raises(LimitError): self.order.add_drink(new_drink, 3) def test_add_side_over_quantity(self): new_side = Side("Fries", 1, 10) with pytest.raises(QuantityError): self.order.add_side(new_side, 20) def test_add_drink_over_quantity(self): new_drink = Drink("Juice", 1, 10) with pytest.raises(QuantityError): self.order.add_drink(new_drink, 20) '''Visual Tests for US1''' i = Ingredient("Cheese", 4, 1) print(i.__str__()) s = Side("Fries", 2, 10, 1) print(s.__str__()) d = Drink("Juice", 3, 10) print(d.__str__())
def test_side_setup_with_limit(): s = Ingredient("fries", 4, 1, 10) assert s.limit == 10
def test_wrap_with_ingredient(self): wrap = Wrap() wrap.add_ingredient(Ingredient("Cheese", 1, 10), 3) assert wrap.cost() == 4
def test_burger_with_ingredient(self): burger = Burger() burger.add_ingredient(Ingredient("Patty", 3, 10), 2) assert burger.cost() == 8
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 setup_method(self): self.ingredient = Ingredient("Cheese", 5, 10)
def test_drink_setup_with_limit(): d = Ingredient("Juice", 4, 1, 10) assert d.limit == 10