def test_retrieve_ingredients_is_successful(self):
    'Test retrieve ingredients'
    Ingredient.objects.create(user=self.user, name='Carrot')
    Ingredient.objects.create(user=self.user, name='Lemon')
    res = self.client.get(INGREDIENTS_URL)
    ingredients = Ingredient.objects.all().order_by('-name')
    serializer = IngredientSerializer(ingredients, many=True)
    self.assertEqual(res.status_code, status.HTTP_200_OK)
    self.assertEqual(res.data, serializer.data)
Test retrieve ingredients
def test_retrieve_ingredients_is_successful(self):
    
    Ingredient.objects.create(user=self.user, name='Carrot')
    Ingredient.objects.create(user=self.user, name='Lemon')
    res = self.client.get(INGREDIENTS_URL)
    ingredients = Ingredient.objects.all().order_by('-name')
    serializer = IngredientSerializer(ingredients, many=True)
    self.assertEqual(res.status_code, status.HTTP_200_OK)
    self.assertEqual(res.data, serializer.data)