Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions promo_code/business/tests/auth/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion promo_code/business/tests/auth/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion promo_code/business/tests/auth/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Expand Down
10 changes: 5 additions & 5 deletions promo_code/business/tests/auth/test_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Expand All @@ -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',
)
Expand All @@ -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',
)
Expand Down Expand Up @@ -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',
)
Expand Down
30 changes: 23 additions & 7 deletions promo_code/business/tests/auth/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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',
)
Expand Down
14 changes: 8 additions & 6 deletions promo_code/business/tests/promocodes/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import django.urls
import rest_framework
import rest_framework.status
import rest_framework.test

import business.models
Expand All @@ -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.',
Expand All @@ -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'],
Expand All @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions promo_code/user/tests/auth/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions promo_code/user/tests/auth/test_authentication.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import rest_framework.status
import rest_framework.test

import user.models
import user.tests.auth.base
Expand All @@ -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',
)
Expand Down
3 changes: 1 addition & 2 deletions promo_code/user/tests/auth/test_registration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import rest_framework.status
import rest_framework.test

import user.models
import user.tests.auth.base
Expand All @@ -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',
)
Expand Down
15 changes: 7 additions & 8 deletions promo_code/user/tests/auth/test_tokens.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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',
)
Expand All @@ -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',
)
Expand All @@ -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',
)
Expand All @@ -91,15 +90,15 @@ 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',
)

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',
)
Expand Down Expand Up @@ -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()),
Expand Down
Loading