diff --git a/apps/account/tests/tests_back.py b/apps/account/tests/tests_back.py index 8adc6b35..d0178159 100644 --- a/apps/account/tests/tests_back.py +++ b/apps/account/tests/tests_back.py @@ -1,10 +1,13 @@ -from rest_framework.test import APITestCase -from rest_framework import status -from authorization.tests.tests_authorization import get_tokens_for_user -from django.urls import reverse from http.cookies import SimpleCookie + +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from account.models import Role, User +from authorization.tests.tests_authorization import get_tokens_for_user from location.models import Country -from account.models import Role, User, UserRole + class RoleTests(APITestCase): def setUp(self): @@ -65,9 +68,11 @@ class UserRoleTests(APITestCase): ) self.role.save() - self.user_test = User.objects.create_user(username='test', - email='testemail@mail.com', - password='passwordtest') + self.user_test = User.objects.create_user( + username='test', + email='testemail@mail.com', + password='passwordtest' + ) def test_user_role_post(self): url = reverse('back:account:user-role-list-create') diff --git a/apps/account/tests/tests_common.py b/apps/account/tests/tests_common.py index dea807c4..67dfacda 100644 --- a/apps/account/tests/tests_common.py +++ b/apps/account/tests/tests_common.py @@ -1,9 +1,11 @@ -from rest_framework.test import APITestCase -from rest_framework import status -from authorization.tests.tests_authorization import get_tokens_for_user from http.cookies import SimpleCookie -from account.models import User + from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from account.models import User +from authorization.tests.tests_authorization import get_tokens_for_user class AccountUserTests(APITestCase): @@ -62,7 +64,7 @@ class AccountChangePasswordTests(APITestCase): self.assertEqual(response.status_code, status.HTTP_200_OK) -class AccountChangePasswordTests(APITestCase): +class AccountConfirmEmail(APITestCase): def setUp(self): self.data = get_tokens_for_user() diff --git a/apps/authorization/tests/tests_authorization.py b/apps/authorization/tests/tests_authorization.py index a6a49ea5..cc0881f5 100644 --- a/apps/authorization/tests/tests_authorization.py +++ b/apps/authorization/tests/tests_authorization.py @@ -1,7 +1,7 @@ -from rest_framework.test import APITestCase -from account.models import User from django.urls import reverse -# Create your tests here. +from rest_framework.test import APITestCase + +from account.models import User def get_tokens_for_user( @@ -28,7 +28,7 @@ class AuthorizationTests(APITestCase): self.password = data["password"] def LoginTests(self): - data ={ + data = { 'username_or_email': self.username, 'password': self.password, 'remember': True diff --git a/apps/comment/tests.py b/apps/comment/tests.py index 9b060f4e..bd22214a 100644 --- a/apps/comment/tests.py +++ b/apps/comment/tests.py @@ -1,11 +1,13 @@ -from utils.tests.tests_permissions import BasePermissionTests -from rest_framework import status -from authorization.tests.tests_authorization import get_tokens_for_user -from django.urls import reverse -from django.contrib.contenttypes.models import ContentType from http.cookies import SimpleCookie + +from django.contrib.contenttypes.models import ContentType +from django.urls import reverse +from rest_framework import status + from account.models import Role, User, UserRole +from authorization.tests.tests_authorization import get_tokens_for_user from comment.models import Comment +from utils.tests.tests_permissions import BasePermissionTests class CommentModeratorPermissionTests(BasePermissionTests): @@ -40,7 +42,6 @@ class CommentModeratorPermissionTests(BasePermissionTests): self.comment.save() self.url = reverse('back:comment:comment-crud', kwargs={"id": self.comment.id}) - def test_put_moderator(self): tokens = User.create_jwt_tokens(self.moderator) self.client.cookies = SimpleCookie( diff --git a/apps/establishment/tests.py b/apps/establishment/tests.py index 43aa62c6..cc9ed152 100644 --- a/apps/establishment/tests.py +++ b/apps/establishment/tests.py @@ -20,13 +20,14 @@ class BaseTestCase(APITestCase): self.newsletter = True self.user = User.objects.create_user( username=self.username, email=self.email, password=self.password) - #get tokkens - tokkens = User.create_jwt_tokens(self.user) + # get tokens + tokens = User.create_jwt_tokens(self.user) self.client.cookies = SimpleCookie( - {'access_token': tokkens.get('access_token'), - 'refresh_token': tokkens.get('refresh_token')}) + {'access_token': tokens.get('access_token'), + 'refresh_token': tokens.get('refresh_token')}) - self.establishment_type = EstablishmentType.objects.create(name="Test establishment type") + self.establishment_type = EstablishmentType.objects.create( + name="Test establishment type") # Create lang object self.lang = Language.objects.get( @@ -42,12 +43,15 @@ class BaseTestCase(APITestCase): country=self.country_ru) self.region.save() - self.city = City.objects.create(name='Mosocow', code='01', - region=self.region, country=self.country_ru) + self.city = City.objects.create( + name='Mosocow', code='01', + region=self.region, + country=self.country_ru) self.city.save() - self.address = Address.objects.create(city=self.city, street_name_1='Krasnaya', - number=2, postal_code='010100') + self.address = Address.objects.create( + city=self.city, street_name_1='Krasnaya', + number=2, postal_code='010100') self.address.save() self.role = Role.objects.create(role=Role.ESTABLISHMENT_MANAGER) @@ -63,8 +67,9 @@ class BaseTestCase(APITestCase): self.establishment.save() - self.user_role = UserRole.objects.create(user=self.user, role=self.role, - establishment=self.establishment) + self.user_role = UserRole.objects.create( + user=self.user, role=self.role, + establishment=self.establishment) self.user_role.save() @@ -128,12 +133,11 @@ class EmployeeTests(BaseTestCase): self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) -# Class to test childs class ChildTestCase(BaseTestCase): def setUp(self): super().setUp() -# Test childs + class EmailTests(ChildTestCase): def setUp(self): super().setUp() diff --git a/apps/favorites/tests.py b/apps/favorites/tests.py index cebd43c2..5f0a2fcd 100644 --- a/apps/favorites/tests.py +++ b/apps/favorites/tests.py @@ -61,9 +61,6 @@ class BaseTestCase(APITestCase): description={"en-GB": "description of test establishment"}, establishment_type=self.test_establishment_type, is_publish=True) - # value for GenericRelation(reverse side) field must be iterable - # value for GenericRelation(reverse side) field must be assigned through - # "set" method of field self.test_establishment.favorites.set([self.test_favorites]) diff --git a/apps/location/tests.py b/apps/location/tests.py index cb574036..4e192831 100644 --- a/apps/location/tests.py +++ b/apps/location/tests.py @@ -19,15 +19,10 @@ class BaseTestCase(APITestCase): self.user = User.objects.create_user( username=self.username, email=self.email, password=self.password) - # get tokens - - # self.user.is_superuser = True - # self.user.save() - - tokkens = User.create_jwt_tokens(self.user) + tokens = User.create_jwt_tokens(self.user) self.client.cookies = SimpleCookie( - {'access_token': tokkens.get('access_token'), - 'refresh_token': tokkens.get('refresh_token')}) + {'access_token': tokens.get('access_token'), + 'refresh_token': tokens.get('refresh_token')}) self.lang = Language.objects.get( title='Russia', @@ -102,7 +97,6 @@ class RegionTests(BaseTestCase): user_role.save() - def test_region_CRUD(self): response = self.client.get('/api/back/location/regions/', format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) diff --git a/apps/notification/tests.py b/apps/notification/tests.py index d78c7fca..87264435 100644 --- a/apps/notification/tests.py +++ b/apps/notification/tests.py @@ -15,10 +15,10 @@ class BaseTestCase(APITestCase): self.password = 'sedragurdaredips19' self.email = 'sedragurda@desoz.com' self.user = User.objects.create_user(username=self.username, email=self.email, password=self.password) - # get tokkens - tokkens = User.create_jwt_tokens(self.user) - self.client.cookies = SimpleCookie({'access_token': tokkens.get('access_token'), - 'refresh_token': tokkens.get('refresh_token')}) + # get tokens + tokens = User.create_jwt_tokens(self.user) + self.client.cookies = SimpleCookie({'access_token': tokens.get('access_token'), + 'refresh_token': tokens.get('refresh_token')}) class NotificationAnonSubscribeTestCase(APITestCase): diff --git a/apps/recipe/tests.py b/apps/recipe/tests.py index d0a17a36..68359be0 100644 --- a/apps/recipe/tests.py +++ b/apps/recipe/tests.py @@ -27,7 +27,5 @@ class BaseTestCase(APITestCase): self.assertEqual(response.status_code, status.HTTP_200_OK) def test_recipe_detail(self): - print(self.test_recipe.id) response = self.client.get(f"/api/web/recipes/{self.test_recipe.id}/") - print(response.json()) self.assertEqual(response.status_code, status.HTTP_200_OK) diff --git a/apps/utils/tests/tests_translated.py b/apps/utils/tests/tests_translated.py index 77b67d8a..4569ecf2 100644 --- a/apps/utils/tests/tests_translated.py +++ b/apps/utils/tests/tests_translated.py @@ -62,7 +62,6 @@ class TranslateFieldTests(BaseTestCase): response = self.client.get(f"/api/web/news/slug/{self.news_item.slug}/", format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) news_data = response.json() - print(news_data) self.assertIn("title_translated", news_data) self.assertIn("Test news item", news_data['title_translated'])