def setUp(self): InitializeRecipes.setUp(self) self.recipe_data, _ = get_recipe_data_flat('lekker') self.recipe_data['instructions'] = "Stir well for 20 minutes" self.recipe_data['ingredients'][1]['ingredient']['name'] = "onion" self.recipe_data['ingredients'][1]['ingredient']['plural'] = "onions" self.recipe_data['ingredients'][0]['amount']['quantity'] = 3
def test_serializer_update_recipe(self): recipe_data, _ = get_recipe_data_flat('lekker') recipe_data['instructions'] = "Stir well for 20 minutes" recipe, _ = Recipe.recipes.get(pk=self.lekker.pk) serializer = RecipeSerializer(recipe, data=recipe_data) self.assertTrue(serializer.is_valid()) recipe = serializer.save() self.compare_object_values(recipe, get_recipe_no_ingredients(recipe_data))
def test_serializer_create(self): recipe_data, expected_recipe = get_recipe_data_flat('frozen_pizza') serializer = RecipeSerializer(data=recipe_data) self.assertTrue(serializer.is_valid()) recipe = serializer.save() ingredient_amounts = get_ingredient_amounts(recipe) self.compare_object_values(recipe, expected_recipe) for i, ingredient in enumerate(recipe_data['ingredients']): self.compare_object_values(ingredient_amounts[i], ingredient)
def test_data_serializer(self): recipe_data, expected_recipe = get_recipe_data_flat('frozen_pizza') serializer = RecipeSerializer(data=recipe_data) self.assertTrue(serializer.is_valid()) serializer_recipe = get_recipe_no_ingredients(serializer.data) self.compare_values(serializer_recipe, expected_recipe) for i, ingredient in enumerate(recipe_data['ingredients']): self.compare_values(serializer.validated_data['ingredients'][i], ingredient)
def test_serializer_update_recipe_ingredients(self): recipe_data, expected_recipe = get_recipe_data_flat('lekker') recipe_data['ingredients'][1]['ingredient']['name'] = "onion" recipe_data['ingredients'][1]['ingredient']['plural'] = "onions" recipe, _ = Recipe.recipes.get(pk=self.lekker.pk) serializer = RecipeSerializer(recipe, data=recipe_data) self.assertTrue(serializer.is_valid()) recipe = serializer.save() ingredient_amounts = get_ingredient_amounts(recipe) self.compare_object_values(recipe, expected_recipe) for i, ingredient in enumerate(recipe_data['ingredients']): self.compare_object_values(ingredient_amounts[i], ingredient)
def setUp(self): Authenticate.setUp(self) self.recipe_data, self.expected_recipe = get_recipe_data_flat('lekker')
def setUp(self): self.recipe_data, self.expected_recipe = get_recipe_data_flat('lekker')
def setUp(self): InitializeRecipes.setUp(self) Authenticate.setUp(self) self.recipe_data, self.expected_recipe = get_recipe_data_flat('lekker')