def test_retrieved_ingredients_limited_to_user(self):
    "Tests that only the user's ingredients are retrieved"
    user2 = create_user(fname='Test2', lname='User2', email='example@example.com', password='test2pass')
    Ingredient.objects.create(user=user2, name='Carrot')
    ingredient = Ingredient.objects.create(user=self.user, name='Lemon')
    res = self.client.get(INGREDIENTS_URL)
    self.assertEqual(res.status_code, status.HTTP_200_OK)
    self.assertEqual(len(res.data), 1)
    self.assertEqual(res.data[0]['name'], ingredient.name)
Tests that only the user's ingredients are retrieved
def test_retrieved_ingredients_limited_to_user(self):
    
    user2 = create_user(fname='Test2', lname='User2', email='example@example.com', password='test2pass')
    Ingredient.objects.create(user=user2, name='Carrot')
    ingredient = Ingredient.objects.create(user=self.user, name='Lemon')
    res = self.client.get(INGREDIENTS_URL)
    self.assertEqual(res.status_code, status.HTTP_200_OK)
    self.assertEqual(len(res.data), 1)
    self.assertEqual(res.data[0]['name'], ingredient.name)