diff --git a/app/recipe/tests/test_recipe_api.py b/app/recipe/tests/test_recipe_api.py index fba0344..eb29bc3 100644 --- a/app/recipe/tests/test_recipe_api.py +++ b/app/recipe/tests/test_recipe_api.py @@ -2,9 +2,8 @@ Test for recipe APIs. """ from decimal import Decimal -from operator import itemgetter -from django.contrib.auth import get_user, get_user_model +from django.contrib.auth import get_user_model from django.test import TestCase from django. urls import reverse @@ -65,7 +64,10 @@ class PrivateRecipeApiTests(TestCase): def setUp(self): self.client = APIClient() - self.user = create_user(email='user@example.com', password='testpass123') + self.user = create_user( + email='user@example.com', + password='testpass123' + ) self.client.force_authenticate(self.user) def test_retrive_recipes(self): @@ -83,7 +85,10 @@ class PrivateRecipeApiTests(TestCase): def test_recipe_list_limited_to_user(self): """Test list of recipes is limited to authenticated user.""" - other_user = create_user(email='other@example.com', password='password123') + other_user = create_user( + email='other@example.com', + password='password123' + ) create_recipe(user=other_user) create_recipe(user=self.user) @@ -165,13 +170,16 @@ class PrivateRecipeApiTests(TestCase): def test_update_user_returns_error(self): """Test changing the recipe user results in an error.""" - new_user = create_user(email='user2@example.com', password='testpass123') + new_user = create_user( + email='user2@example.com', + password='testpass123' + ) recipe = create_recipe(user=self.user) payload = {'user': new_user.id} url = detail_url(recipe.id) self.client.patch(url, payload) - + recipe.refresh_from_db() self.assertEqual(recipe.user, self.user) @@ -187,7 +195,10 @@ class PrivateRecipeApiTests(TestCase): def test_recipe_other_users_recipe_error(self): """Test trying to delete another users recipe gives error.""" - new_user = create_user(email='user2@example.com', password='testpass123') + new_user = create_user( + email='user2@example.com', + password='testpass123' + ) recipe = create_recipe(user=new_user) url = detail_url(recipe.id)