pass flake8

This commit is contained in:
devfzn 2023-10-09 15:39:28 -03:00
parent fe9ee4c11a
commit b41d4ea06e
Signed by: devfzn
GPG Key ID: E070ECF4A754FDB1

View File

@ -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)