def test_get_recipes_with_ingredients(self):
    'Test retrieving a recipe including ingredients'
    self.recipe = create_sample_recipe(name='Carrot Cake', description='Sponge cake with hella carrots.')
    Ingredient.objects.create(name='Carrots', recipe=self.recipe)
    Ingredient.objects.create(name='Icing Sugar', recipe=self.recipe)
    response = self.client.get(RECIPE_URL)
    ingredients = Ingredient.objects.all()
    self.assertEqual(response.status_code, status.HTTP_200_OK)
    self.assertEquals(len(response.data[0]['ingredients']), len(ingredients))
Test retrieving a recipe including ingredients
def test_get_recipes_with_ingredients(self):
    
    self.recipe = create_sample_recipe(name='Carrot Cake', description='Sponge cake with hella carrots.')
    Ingredient.objects.create(name='Carrots', recipe=self.recipe)
    Ingredient.objects.create(name='Icing Sugar', recipe=self.recipe)
    response = self.client.get(RECIPE_URL)
    ingredients = Ingredient.objects.all()
    self.assertEqual(response.status_code, status.HTTP_200_OK)
    self.assertEquals(len(response.data[0]['ingredients']), len(ingredients))