diff --git a/promo_code/business/tests/auth/base.py b/promo_code/business/tests/auth/base.py index ba8dee5..ca100d2 100644 --- a/promo_code/business/tests/auth/base.py +++ b/promo_code/business/tests/auth/base.py @@ -15,8 +15,12 @@ def setUpTestData(cls): 'api-business:company-token-refresh', ) cls.protected_url = django.urls.reverse('api-core:protected') - cls.signup_url = django.urls.reverse('api-business:company-sign-up') - cls.signin_url = django.urls.reverse('api-business:company-sign-in') + cls.company_signup_url = django.urls.reverse( + 'api-business:company-sign-up', + ) + cls.company_signin_url = django.urls.reverse( + 'api-business:company-sign-in', + ) cls.valid_data = { 'name': 'Digital Marketing Solutions Inc.', 'email': 'testcompany@example.com', diff --git a/promo_code/business/tests/auth/test_authentication.py b/promo_code/business/tests/auth/test_authentication.py index e5bd1b7..4a0d357 100644 --- a/promo_code/business/tests/auth/test_authentication.py +++ b/promo_code/business/tests/auth/test_authentication.py @@ -20,7 +20,7 @@ def test_signin_success(self): ) response = self.client.post( - self.signin_url, + self.company_signin_url, { 'email': registration_data['email'], 'password': registration_data['password'], diff --git a/promo_code/business/tests/auth/test_registration.py b/promo_code/business/tests/auth/test_registration.py index f6762b1..0920b12 100644 --- a/promo_code/business/tests/auth/test_registration.py +++ b/promo_code/business/tests/auth/test_registration.py @@ -11,7 +11,7 @@ class TestCompanyRegistration( def test_registration_success(self): registration_data = {**self.valid_data, 'email': 'unique@company.com'} response = self.client.post( - self.signup_url, + self.company_signup_url, registration_data, format='json', ) diff --git a/promo_code/business/tests/auth/test_tokens.py b/promo_code/business/tests/auth/test_tokens.py index e2d41f6..21f726f 100644 --- a/promo_code/business/tests/auth/test_tokens.py +++ b/promo_code/business/tests/auth/test_tokens.py @@ -23,7 +23,7 @@ def setUp(self): def test_access_protected_view_with_valid_token(self): response = self.client.post( - self.signin_url, + self.company_signin_url, self.user_data, format='json', ) @@ -45,7 +45,7 @@ def test_registration_token_invalid_after_login(self): 'name': 'Digital Marketing Solutions Inc.', } response = self.client.post( - self.signup_url, + self.company_signup_url, data, format='json', ) @@ -62,7 +62,7 @@ def test_registration_token_invalid_after_login(self): login_data = {'email': data['email'], 'password': data['password']} response = self.client.post( - self.signin_url, + self.company_signin_url, login_data, format='json', ) @@ -214,14 +214,14 @@ def test_company_not_found(self): def test_refresh_token_invalidation_after_new_login(self): first_login_response = self.client.post( - self.signin_url, + self.company_signin_url, self.company_data, format='json', ) refresh_token_v1 = first_login_response.data['refresh'] second_login_response = self.client.post( - self.signin_url, + self.company_signin_url, self.company_data, format='json', ) diff --git a/promo_code/business/tests/auth/test_validation.py b/promo_code/business/tests/auth/test_validation.py index 8f3f8d6..7b453f4 100644 --- a/promo_code/business/tests/auth/test_validation.py +++ b/promo_code/business/tests/auth/test_validation.py @@ -22,7 +22,7 @@ def test_duplicate_email_registration(self): ) response = self.client.post( - self.signup_url, + self.company_signup_url, self.valid_data, format='json', ) @@ -46,7 +46,11 @@ def test_duplicate_email_registration(self): ) def test_invalid_password_cases(self, _, invalid_password): test_data = {**self.valid_data, 'password': invalid_password} - response = self.client.post(self.signup_url, test_data, format='json') + response = self.client.post( + self.company_signup_url, + test_data, + format='json', + ) self.assertEqual( response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, @@ -64,7 +68,11 @@ def test_invalid_password_cases(self, _, invalid_password): ) def test_invalid_email_cases(self, _, invalid_email): test_data = {**self.valid_data, 'email': invalid_email} - response = self.client.post(self.signup_url, test_data, format='json') + response = self.client.post( + self.company_signup_url, + test_data, + format='json', + ) self.assertEqual( response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, @@ -73,7 +81,11 @@ def test_invalid_email_cases(self, _, invalid_email): def test_short_company_name(self): test_data = {**self.valid_data, 'name': 'A'} - response = self.client.post(self.signup_url, test_data, format='json') + response = self.client.post( + self.company_signup_url, + test_data, + format='json', + ) self.assertEqual( response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, @@ -90,8 +102,12 @@ class InvalidCompanyAuthenticationTestCase( ('empty_data', {}, ['email', 'password']), ], ) - def test_missing_required_fields(self, case_name, data, expected_fields): - response = self.client.post(self.signin_url, data, format='json') + def test_missing_required_fields(self, _, data, expected_fields): + response = self.client.post( + self.company_signin_url, + data, + format='json', + ) self.assertEqual( response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, @@ -109,7 +125,7 @@ def test_signin_invalid_password(self): 'password': 'SuperInvalidPassword2000!', } response = self.client.post( - self.signin_url, + self.company_signin_url, data, format='json', ) diff --git a/promo_code/business/tests/promocodes/base.py b/promo_code/business/tests/promocodes/base.py index 35d3ca3..9a7ebf6 100644 --- a/promo_code/business/tests/promocodes/base.py +++ b/promo_code/business/tests/promocodes/base.py @@ -1,6 +1,4 @@ import django.urls -import rest_framework -import rest_framework.status import rest_framework.test import business.models @@ -14,8 +12,12 @@ def setUpTestData(cls): cls.promo_list_create_url = django.urls.reverse( 'api-business:promo-list-create', ) - cls.signup_url = django.urls.reverse('api-business:company-sign-up') - cls.signin_url = django.urls.reverse('api-business:company-sign-in') + cls.company_signup_url = django.urls.reverse( + 'api-business:company-sign-up', + ) + cls.company_signin_url = django.urls.reverse( + 'api-business:company-sign-in', + ) cls.company1_data = { 'name': 'Digital Marketing Solutions Inc.', @@ -38,7 +40,7 @@ def setUpTestData(cls): ) response1 = cls.client.post( - cls.signin_url, + cls.company_signin_url, { 'email': cls.company1_data['email'], 'password': cls.company1_data['password'], @@ -48,7 +50,7 @@ def setUpTestData(cls): cls.company1_token = response1.data['access'] response2 = cls.client.post( - cls.signin_url, + cls.company_signin_url, { 'email': cls.company2_data['email'], 'password': cls.company2_data['password'], diff --git a/promo_code/business/tests/promocodes/validations/test_create_validation.py b/promo_code/business/tests/promocodes/validations/test_create_validation.py index 0ab1a98..f837a09 100644 --- a/promo_code/business/tests/promocodes/validations/test_create_validation.py +++ b/promo_code/business/tests/promocodes/validations/test_create_validation.py @@ -21,13 +21,13 @@ def test_create_promo_with_old_token(self): 'password': 'SuperStrongPassword2000!', } reg_response = self.client.post( - self.signup_url, + self.company_signup_url, registration_data, format='json', ) old_token = reg_response.data.get('token') self.client.post( - self.signin_url, + self.company_signin_url, { 'email': registration_data['email'], 'password': registration_data['password'], @@ -94,7 +94,7 @@ def test_create_promo_with_old_token(self): ), ], ) - def test_missing_fields(self, name, payload): + def test_missing_fields(self, _, payload): response = self.client.post( self.promo_list_create_url, payload, @@ -349,7 +349,7 @@ def test_too_short_promo_common(self): ), ], ) - def test_invalid_type_payloads(self, name, payload): + def test_invalid_type_payloads(self, _, payload): response = self.client.post( self.promo_list_create_url, payload, diff --git a/promo_code/business/tests/promocodes/validations/test_detail_validation.py b/promo_code/business/tests/promocodes/validations/test_detail_validation.py index 26f5574..3699794 100644 --- a/promo_code/business/tests/promocodes/validations/test_detail_validation.py +++ b/promo_code/business/tests/promocodes/validations/test_detail_validation.py @@ -56,7 +56,7 @@ def test_old_token_invalid_after_reauthentication(self): 'password': self.company1_data['password'], } response = self.client.post( - self.signin_url, + self.company_signin_url, signin_payload, format='json', ) diff --git a/promo_code/business/tests/promocodes/validations/test_list_validation.py b/promo_code/business/tests/promocodes/validations/test_list_validation.py index 0953817..595ccab 100644 --- a/promo_code/business/tests/promocodes/validations/test_list_validation.py +++ b/promo_code/business/tests/promocodes/validations/test_list_validation.py @@ -46,7 +46,7 @@ def test_get_promos_without_token(self): ), ], ) - def test_invalid_query_string_parameters(self, name, params): + def test_invalid_query_string_parameters(self, _, params): response = self.client.get(self.promo_list_create_url, params) self.assertEqual( response.status_code, @@ -65,7 +65,7 @@ def test_invalid_query_string_parameters(self, name, params): ('empty_string_offset', {'offset': ''}), ], ) - def test_invalid_numeric_parameters(self, name, params): + def test_invalid_numeric_parameters(self, _, params): response = self.client.get(self.promo_list_create_url, params) self.assertEqual( response.status_code, diff --git a/promo_code/user/tests/auth/base.py b/promo_code/user/tests/auth/base.py index 66c49ed..467666d 100644 --- a/promo_code/user/tests/auth/base.py +++ b/promo_code/user/tests/auth/base.py @@ -12,8 +12,8 @@ def setUpTestData(cls): cls.client = rest_framework.test.APIClient() cls.protected_url = django.urls.reverse('api-core:protected') cls.refresh_url = django.urls.reverse('api-user:user-token-refresh') - cls.signup_url = django.urls.reverse('api-user:sign-up') - cls.signin_url = django.urls.reverse('api-user:sign-in') + cls.user_signup_url = django.urls.reverse('api-user:user-sign-up') + cls.user_signin_url = django.urls.reverse('api-user:user-sign-in') def tearDown(self): user.models.User.objects.all().delete() diff --git a/promo_code/user/tests/auth/test_authentication.py b/promo_code/user/tests/auth/test_authentication.py index e545ff7..2cefd79 100644 --- a/promo_code/user/tests/auth/test_authentication.py +++ b/promo_code/user/tests/auth/test_authentication.py @@ -1,5 +1,4 @@ import rest_framework.status -import rest_framework.test import user.models import user.tests.auth.base @@ -20,7 +19,7 @@ def test_signin_success(self): 'password': 'SuperStrongPassword2000!', } response = self.client.post( - self.signin_url, + self.user_signin_url, data, format='json', ) diff --git a/promo_code/user/tests/auth/test_registration.py b/promo_code/user/tests/auth/test_registration.py index 1759ce2..9d6ddce 100644 --- a/promo_code/user/tests/auth/test_registration.py +++ b/promo_code/user/tests/auth/test_registration.py @@ -1,5 +1,4 @@ import rest_framework.status -import rest_framework.test import user.models import user.tests.auth.base @@ -15,7 +14,7 @@ def test_registration_success(self): 'other': {'age': 23, 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, valid_data, format='json', ) diff --git a/promo_code/user/tests/auth/test_tokens.py b/promo_code/user/tests/auth/test_tokens.py index 3b6f872..8ad82c3 100644 --- a/promo_code/user/tests/auth/test_tokens.py +++ b/promo_code/user/tests/auth/test_tokens.py @@ -1,5 +1,4 @@ import rest_framework.status -import rest_framework.test import rest_framework_simplejwt.token_blacklist.models as tb_models import user.models @@ -24,7 +23,7 @@ def setUp(self): def test_access_protected_view_with_valid_token(self): response = self.client.post( - self.signin_url, + self.user_signin_url, self.user_data, format='json', ) @@ -48,7 +47,7 @@ def test_registration_token_invalid_after_login(self): 'other': {'age': 22, 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -65,7 +64,7 @@ def test_registration_token_invalid_after_login(self): login_data = {'email': data['email'], 'password': data['password']} response = self.client.post( - self.signin_url, + self.user_signin_url, login_data, format='json', ) @@ -91,7 +90,7 @@ def test_registration_token_invalid_after_login(self): def test_refresh_token_invalidation_after_new_login(self): first_login_response = self.client.post( - self.signin_url, + self.user_signin_url, self.user_data, format='json', ) @@ -99,7 +98,7 @@ def test_refresh_token_invalidation_after_new_login(self): refresh_token_v1 = first_login_response.data['refresh'] second_login_response = self.client.post( - self.signin_url, + self.user_signin_url, self.user_data, format='json', ) @@ -141,9 +140,9 @@ def test_refresh_token_invalidation_after_new_login(self): ) def test_blacklist_storage(self): - self.client.post(self.signin_url, self.user_data, format='json') + self.client.post(self.user_signin_url, self.user_data, format='json') - self.client.post(self.signin_url, self.user_data, format='json') + self.client.post(self.user_signin_url, self.user_data, format='json') self.assertEqual( (tb_models.BlacklistedToken.objects.count()), diff --git a/promo_code/user/tests/auth/test_validation.py b/promo_code/user/tests/auth/test_validation.py index ee40435..1ca517d 100644 --- a/promo_code/user/tests/auth/test_validation.py +++ b/promo_code/user/tests/auth/test_validation.py @@ -1,6 +1,5 @@ import parameterized import rest_framework.status -import rest_framework.test import user.models import user.tests.auth.base @@ -18,7 +17,7 @@ def test_email_duplication(self): 'other': {'age': 23, 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, valid_data, format='json', ) @@ -35,7 +34,7 @@ def test_email_duplication(self): 'other': {'age': 14, 'country': 'fr'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, duplicate_data, format='json', ) @@ -66,7 +65,7 @@ def test_weak_password_cases(self, case_name, password): } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -102,7 +101,7 @@ def test_invalid_avatar_urls(self, name, url, email): } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -122,7 +121,7 @@ def test_missing_country_field(self): 'other': {'age': 23}, } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -144,7 +143,7 @@ def test_invalid_country_code(self): } response = self.client.post( - self.signup_url, + self.user_signup_url, invalid_data, format='json', ) @@ -164,7 +163,7 @@ def test_invalid_age_type(self): 'other': {'age': '23aaaaaa', 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -182,7 +181,7 @@ def test_missing_age_field(self): 'other': {'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -200,7 +199,7 @@ def test_negative_age_value(self): 'other': {'age': -20, 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -227,7 +226,7 @@ def test_invalid_email_formats(self, name, email): } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -247,7 +246,7 @@ def test_empty_name_field(self): 'other': {'age': 23, 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -265,7 +264,7 @@ def test_empty_surname_field(self): 'other': {'age': 23, 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, data, format='json', ) @@ -285,8 +284,8 @@ class InvalidUserAuthenticationTestCase( ('empty_data', {}, ['email', 'password']), ], ) - def test_missing_required_fields(self, case_name, data, expected_fields): - response = self.client.post(self.signin_url, data, format='json') + def test_missing_required_fields(self, _, data, expected_fields): + response = self.client.post(self.user_signin_url, data, format='json') self.assertEqual( response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST, @@ -312,7 +311,7 @@ def test_signin_invalid_password(self): 'password': 'SuperInvalidPassword2000!', } response = self.client.post( - self.signin_url, + self.user_signin_url, data, format='json', ) diff --git a/promo_code/user/tests/user/base.py b/promo_code/user/tests/user/base.py index f632274..9ad6df2 100644 --- a/promo_code/user/tests/user/base.py +++ b/promo_code/user/tests/user/base.py @@ -11,8 +11,8 @@ class BaseUserTestCase(rest_framework.test.APITestCase): def setUpTestData(cls): super().setUpTestData() cls.client = rest_framework.test.APIClient() - cls.signup_url = django.urls.reverse('api-user:sign-up') - cls.signin_url = django.urls.reverse('api-user:sign-in') + cls.user_signup_url = django.urls.reverse('api-user:user-sign-up') + cls.user_signin_url = django.urls.reverse('api-user:user-sign-in') cls.user_profile_url = django.urls.reverse('api-user:user-profile') cls.promo_list_create_url = django.urls.reverse( 'api-business:promo-list-create', diff --git a/promo_code/user/tests/user/operations/test_detail.py b/promo_code/user/tests/user/operations/test_detail.py index d84a1c2..0dbbec0 100644 --- a/promo_code/user/tests/user/operations/test_detail.py +++ b/promo_code/user/tests/user/operations/test_detail.py @@ -17,7 +17,7 @@ def setUp(self): 'other': {'age': 80, 'country': 'sg'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, signup_payload, format='json', ) diff --git a/promo_code/user/tests/user/operations/test_profile.py b/promo_code/user/tests/user/operations/test_profile.py index b0cb470..a65512d 100644 --- a/promo_code/user/tests/user/operations/test_profile.py +++ b/promo_code/user/tests/user/operations/test_profile.py @@ -14,7 +14,7 @@ def setUp(self): 'other': {'age': 23, 'country': 'us'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, signup_data, format='json', ) @@ -113,7 +113,7 @@ def test_auth_sign_in_old_password_fails(self): ) self.client.credentials() response = self.client.post( - self.signin_url, + self.user_signin_url, { 'email': 'creator@apple.com', 'password': 'WhoLivesInCalifornia2000!', @@ -134,7 +134,7 @@ def test_auth_sign_in_new_password_succeeds(self): ) self.client.credentials() response = self.client.post( - self.signin_url, + self.user_signin_url, { 'email': 'creator@apple.com', 'password': 'MegaGiant88888@dooRuveS', diff --git a/promo_code/user/tests/user/validations/test_profile_validation.py b/promo_code/user/tests/user/validations/test_profile_validation.py index 980a36c..592b9a5 100644 --- a/promo_code/user/tests/user/validations/test_profile_validation.py +++ b/promo_code/user/tests/user/validations/test_profile_validation.py @@ -15,7 +15,7 @@ def setUp(self): 'other': {'age': 48, 'country': 'gb'}, } response = self.client.post( - self.signup_url, + self.user_signup_url, signup_data, format='json', ) @@ -41,7 +41,7 @@ def test_update_profile_empty_name_and_surname(self): ('no_domain', 'https://.com'), ], ) - def test_update_profile_invalid_avatar_url(self, name, url): + def test_update_profile_invalid_avatar_url(self, _, url): payload = {'avatar_url': url} response = self.client.patch( self.user_profile_url, @@ -66,7 +66,7 @@ def test_update_profile_invalid_avatar_url(self, name, url): ('repeating_pattern', '11111@@@@@aaaaa'), ], ) - def test_update_profile_weak_password(self, name, pwd): + def test_update_profile_weak_password(self, _, pwd): payload = {'password': pwd} response = self.client.patch( self.user_profile_url, diff --git a/promo_code/user/urls.py b/promo_code/user/urls.py index b53edc4..4142ae1 100644 --- a/promo_code/user/urls.py +++ b/promo_code/user/urls.py @@ -10,12 +10,12 @@ django.urls.path( 'auth/sign-up', user.views.UserSignUpView.as_view(), - name='sign-up', + name='user-sign-up', ), django.urls.path( 'auth/sign-in', user.views.UserSignInView.as_view(), - name='sign-in', + name='user-sign-in', ), django.urls.path( 'token/refresh/',