Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandgeider committed Nov 9, 2024
1 parent 109338c commit d92bb66
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions wger/core/tests/test_user_rest_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test_post_valid_api_user_creation(self):
response = self.client.post(
reverse('api_register'),
{'username': 'restapi', 'email': 'abc@cde.fg', 'password': 'AekaiLe0ga'},
Authorization=f'Token {token.key}',
)
count_after = User.objects.count()
self.assertEqual(response.status_code, HTTP_201_CREATED)
Expand All @@ -91,7 +90,6 @@ def test_post_valid_api_user_creation_no_email(self):
response = self.client.post(
reverse('api_register'),
{'username': 'restapi', 'password': 'AekaiLe0ga'},
Authorization=f'Token {token.key}',
)
count_after = User.objects.count()
self.assertEqual(response.status_code, HTTP_201_CREATED)
Expand All @@ -102,21 +100,6 @@ def test_post_valid_api_user_creation_no_email(self):
self.assertEqual(response.data['token'], token.key)
self.assertEqual(count_after, count_before + 1)

def test_post_not_allowed_api_user_creation(self):
"""User admin isn't allowed to register users"""

self.user_login('admin')
count_before = User.objects.count()

response = self.client.post(
reverse('api_register'),
{'username': 'restapi', 'email': 'abc@cde.fg', 'password': 'AekaiLe0ga'},
)
count_after = User.objects.count()

self.assertEqual(response.status_code, HTTP_403_FORBIDDEN)
self.assertEqual(count_after, count_before)

def test_post_unsuccessfully_registration_no_username(self):
"""Test unsuccessful registration (weak password)"""

Expand All @@ -127,7 +110,6 @@ def test_post_unsuccessfully_registration_no_username(self):
response = self.client.post(
reverse('api_register'),
{'password': 'AekaiLe0ga'},
Authorization=f'Token {token.key}',
)

self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)
Expand All @@ -142,7 +124,6 @@ def test_post_unsuccessfully_registration_invalid_email(self):
response = self.client.post(
reverse('api_register'),
{'username': 'restapi', 'email': 'example.com', 'password': 'AekaiLe0ga'},
Authorization=f'Token {token.key}',
)

self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)
Expand All @@ -157,7 +138,6 @@ def test_post_unsuccessfully_registration_invalid_email_2(self):
response = self.client.post(
reverse('api_register'),
{'username': 'restapi', 'email': 'admin@example.com', 'password': 'AekaiLe0ga'},
Authorization=f'Token {token.key}',
)

self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

0 comments on commit d92bb66

Please sign in to comment.