Skip to content

Commit

Permalink
Finish the unittesting for the user pages routes/status codes & start…
Browse files Browse the repository at this point in the history
… with their content testing.
  • Loading branch information
kirkoov committed Sep 10, 2024
1 parent 6945365 commit ef59ddd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
26 changes: 26 additions & 0 deletions backend/users/tests/test_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.contrib.auth import get_user_model
from django.test import TestCase

from backend import constants

User = get_user_model()


class TestContent(TestCase):
TOTAL = constants.PAGINATOR_NUM + 1

@classmethod
def setUpTestData(cls):
User.objects.bulk_create(
User(
username=f"{constants.TEST_USER_DATA_2['username']}{idx}",
first_name=f"{constants.TEST_USER_DATA_2['first_name']}{idx}",
last_name=f"{constants.TEST_USER_DATA_2['last_name']}{idx}",
email=f"{constants.TEST_USER_DATA_2['email']}{idx}",
password=f"{constants.TEST_USER_DATA_2['password']}{idx}",
)
for idx in range(cls.TOTAL)
)

def test_number_users(self):
self.assertEqual(User.objects.count(), self.TOTAL)
8 changes: 8 additions & 0 deletions backend/users/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,11 @@ def get_token(self, user_data) -> str:
)
self.assertEqual(response.status_code, HTTPStatus.OK)
return tmp_d["auth_token"]

@staticmethod
def delete_test_users():
User.objects.all().delete()

@classmethod
def tearDownClass(cls):
cls.delete_test_users()

0 comments on commit ef59ddd

Please sign in to comment.