def add_food(self, food_name, ingredients): if food_name.get() and (len(ingredients) >= 1): new_food = Food(food_name.get()) for ingredient in ingredients: new_food.add_ingredient(ingredient) # Update the frame self.frames["food_list_ing"] = self.food_list_of_ingredients( self.window, new_food) self.goto_page("food_list_ing") else: print("NONAME")
def test_add_food(self): old_size = len(self.list.food) banana_split = Food( "banana_split" ) # So that the food that we compare have at least two ingredients banana_ing = Ingredient("banana", 75, 60, 0, 5) banana_split.add_ingredient(banana_ing, 100, 100) cream_ing = Ingredient("cream", 190, 100, 10, 50) banana_split.add_ingredient(cream_ing, 25, 45, True) sandwich = Food("sandwich") bread_ing = Ingredient("bread", 100, 80, 0, 20) ham_ing = Ingredient("ham", 60, 5, 30, 10) sandwich.add_ingredient(bread_ing, 100, 100) sandwich.add_ingredient(ham_ing, 100, 100) self.list.add_food(banana_split) # We add the food to the list self.list.add_food(sandwich) # We add the food to the list self.assertEqual(old_size + 2, len( self.list.food)) # We check if the list is bigger by one element