def test_pizza_calculate_total_weight(self): d = Dough("Sugar", "Mixing", 20) t = Topping("Tomato", 20) p = Pizza("Burger", d, 200) p.add_topping(t) p.add_topping(t) self.assertEqual(p.calculate_total_weight(), 60)
def test_pizza_add_topping_error(self): d = Dough("Sugar", "Mixing", 20) t = Topping("Tomato", 20) p = Pizza("Burger", d, 0) with self.assertRaises(ValueError) as ctx: p.add_topping(t) self.assertEqual("Not enough space for another topping", str(ctx.exception))
def test_pizza_add_topping_update(self): d = Dough("Sugar", "Mixing", 20) t = Topping("Tomato", 20) p = Pizza("Burger", d, 200) p.add_topping(t) p.add_topping(t) self.assertEqual(p.toppings["Tomato"], 40)
def test_pizza_init(self): d = Dough("Sugar", "Mixing", 20) p = Pizza("Burger", d, 5) self.assertEqual(p._Pizza__name, "Burger") self.assertEqual(p._Pizza__dough, d) self.assertEqual(len(p._Pizza__toppings), 0) self.assertEqual(p._Pizza__toppings_capacity, 5)
print(tomato_topping.topping_type) print(tomato_topping.weight) mushrooms_topping = Topping("Mushroom", 75) print(mushrooms_topping.topping_type) print(mushrooms_topping.weight) mozzarella_topping = Topping("Mozzarella", 80) print(mozzarella_topping.topping_type) print(mozzarella_topping.weight) cheddar_topping = Topping("Cheddar", 150) pepperoni_topping = Topping("Pepperoni", 120) white_flour_dough = Dough("White Flour", "Mixing", 200) print(white_flour_dough.flour_type) print(white_flour_dough.weight) print(white_flour_dough.baking_technique) whole_wheat_dough = Dough("Whole Wheat Flour", "Mixing", 200) print(whole_wheat_dough.weight) print(whole_wheat_dough.flour_type) print(whole_wheat_dough.baking_technique) p = Pizza("Margherita", whole_wheat_dough, 2) p.add_topping(tomato_topping) print(p.calculate_total_weight()) p.add_topping(mozzarella_topping)
def test_dough_init(self): d = Dough("Sugar", "Mixing", 20) self.assertEqual(d._Dough__flour_type, "Sugar") self.assertEqual(d._Dough__baking_technique, "Mixing") self.assertEqual(d._Dough__weight, 20)
def test_dough_weight_error(self): with self.assertRaises(ValueError) as ve: t = Dough("a", 'ab', -1) self.assertEqual("The weight cannot be less or equal to zero", str(ve.exception))
def test_dough_baking_technique_error(self): with self.assertRaises(ValueError) as ve: d = Dough("ab", '', 20) self.assertEqual("The baking technique cannot be an empty string", str(ve.exception))
def test_dough_flour_type_error(self): with self.assertRaises(ValueError) as ve: d = Dough("", 'ab', 20) self.assertEqual("The flour type cannot be an empty string", str(ve.exception))