def test_update_recipe_ingredients(self):
    'Test updating a recipe with ingredients included'
    self.recipe = create_sample_recipe(name='Roast Dinner', description='Roasted potatoes and chicken with vegetables and gravy.')
    payload = {'name': 'Vegan Roast Dinner', 'description': 'Roasted potatoes and mushroom wellington with vegetables and gravy.', 'ingredients': [{'name': 'carrots'}, {'name': 'potatoes'}, {'name': 'mushrooms'}]}
    response = self.client.patch(recipe_url(self.recipe.id), payload, format='json')
    self.recipe.refresh_from_db()
    ingredients = Ingredient.objects.all()
    self.assertEqual(response.status_code, status.HTTP_200_OK)
    self.assertEqual(len(ingredients), len(payload['ingredients']))
    self.assertEqual(ingredients[0].recipe.name, payload['name'])
Test updating a recipe with ingredients included
def test_update_recipe_ingredients(self):
    
    self.recipe = create_sample_recipe(name='Roast Dinner', description='Roasted potatoes and chicken with vegetables and gravy.')
    payload = {'name': 'Vegan Roast Dinner', 'description': 'Roasted potatoes and mushroom wellington with vegetables and gravy.', 'ingredients': [{'name': 'carrots'}, {'name': 'potatoes'}, {'name': 'mushrooms'}]}
    response = self.client.patch(recipe_url(self.recipe.id), payload, format='json')
    self.recipe.refresh_from_db()
    ingredients = Ingredient.objects.all()
    self.assertEqual(response.status_code, status.HTTP_200_OK)
    self.assertEqual(len(ingredients), len(payload['ingredients']))
    self.assertEqual(ingredients[0].recipe.name, payload['name'])