def test_recipes_limited_to_user(self):
    'Test retrieving recipes for user'
    user2 = get_user_model().objects.create_user('example@example.com', 'otherpass')
    sample_recipe(user=user2)
    sample_recipe(user=self.user)
    res = self.client.get(RECIPE_URL)
    recipes = Recipe.objects.filter(user=self.user)
    serializer = RecipeSerializer(recipes, many=True)
    self.assertEqual(res.status_code, status.HTTP_200_OK)
    self.assertEqual(len(res.data), 1)
    self.assertEqual(res.data, serializer.data)
Test retrieving recipes for user
def test_recipes_limited_to_user(self):
    
    user2 = get_user_model().objects.create_user('example@example.com', 'otherpass')
    sample_recipe(user=user2)
    sample_recipe(user=self.user)
    res = self.client.get(RECIPE_URL)
    recipes = Recipe.objects.filter(user=self.user)
    serializer = RecipeSerializer(recipes, many=True)
    self.assertEqual(res.status_code, status.HTTP_200_OK)
    self.assertEqual(len(res.data), 1)
    self.assertEqual(res.data, serializer.data)