Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

[feature request] Desenvolvimento dos testes #57

Merged
merged 25 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bd4c1ab
test: initial tests development
LuizaMaluf Nov 1, 2023
073bf82
test(auth): User test case
LuizaMaluf Nov 1, 2023
0991d5f
test: User Manager test case
LuizaMaluf Nov 1, 2023
d39d725
test: User Admin test case
LuizaMaluf Nov 1, 2023
558624f
test: User Admin test case
LuizaMaluf Nov 1, 2023
bd2b726
test: Contest model test case
LuizaMaluf Nov 2, 2023
05ee3e8
test: Contest status test case
LuizaMaluf Nov 4, 2023
c57a0f8
test: Contest admin test case
LuizaMaluf Nov 4, 2023
4dfdd5f
test: Contest urls test case
LuizaMaluf Nov 4, 2023
7ab68db
test: Contest urls test case
LuizaMaluf Nov 4, 2023
82701c2
test: Problem test case
LuizaMaluf Nov 6, 2023
a38e29e
test: Problem model form test case with errors
LuizaMaluf Nov 6, 2023
13b8d26
test: Problem URLs test case
LuizaMaluf Nov 6, 2023
62a80ff
test: Problem DetailView test case
LuizaMaluf Nov 6, 2023
6cf5eee
test: Contest View test case
LuizaMaluf Nov 6, 2023
b3099c5
Merge branch 'main' into tests
LuizaMaluf Nov 7, 2023
9657090
Merge branch 'main' into tests
bitterteriyaki Nov 8, 2023
4e76ef1
test(apps/contest): fix some wrong tests
bitterteriyaki Nov 8, 2023
9244895
test(apps/problems): fix problem test with error
bitterteriyaki Nov 8, 2023
7236fcd
test(apps/problems): fix contest URLs test case
bitterteriyaki Nov 8, 2023
a2b5c47
style(apps/problems): add a blank line to make the code cleaner
bitterteriyaki Nov 8, 2023
e95d324
test(apps/problems): fix problems tests
bitterteriyaki Nov 8, 2023
888f906
test(apps/contests): add a test to reversed detail URL
bitterteriyaki Nov 8, 2023
22e98f6
test(apps/problems): fix some tests
bitterteriyaki Nov 8, 2023
38f3091
test(apps/users): fix some tests for user app
bitterteriyaki Nov 8, 2023
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
25 changes: 25 additions & 0 deletions apps/contests/tests_contests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.test import TestCase


class IndexViewTestCase(TestCase):
pass


class DetailViewTestCase(TestCase):
pass


class ContestTestCase(TestCase):
pass


class ContestStatusTestCase(TestCase):
pass


class ContestModelFormTestCase(TestCase):
pass


class ContestAdminTestCase(TestCase):
pass
17 changes: 17 additions & 0 deletions apps/problems/tests_problems.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.test import TestCase


class DetailViewTestCase(TestCase):
pass


class ProblemTestCase(TestCase):
pass


class ProblemModelFormTestCase(TestCase):
pass


class ProblemAdminTestCase(TestCase):
pass
82 changes: 82 additions & 0 deletions apps/users/tests_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from django.test import TestCase

from .admin import UserAdmin
from .models import User
LuizaMaluf marked this conversation as resolved.
Show resolved Hide resolved


class UserModelTestCase(TestCase):
def test_user_fields(self) -> None:
self.user_data = {
"email": "[email protected]",
"username": "user_test",
"password": "testpassword",
}
self.user = User.objects.create(**self.user_data)
LuizaMaluf marked this conversation as resolved.
Show resolved Hide resolved

def test_username_field_is_email(self) -> None:
self.assertEqual(User().USERNAME_FIELD, "email")

def test_required_fields_include_username(self) -> None:
self.assertIn("username", User().REQUIRED_FIELDS)


class UserManagerTestCase(TestCase):
def test_create_user(self) -> None:
user = User.objects.create_user(
username="testuser",
email="[email protected]",
password="testpassword",
)
self.assertEqual(user.email, "[email protected]")
self.assertEqual(user.username, "testuser")
self.assertFalse(user.is_staff)
self.assertTrue(user.is_active)

def test_create_superuser(self) -> None:
superuser = User.objects.create_superuser(
username="adminuser",
email="[email protected]",
password="adminpassword",
)
self.assertEqual(superuser.email, "[email protected]")
self.assertEqual(superuser.username, "adminuser")
self.assertTrue(superuser.is_staff)
self.assertTrue(superuser.is_superuser)


class UserAdminTestCase(TestCase):
def test_list_display(self) -> None:
self.assertEqual(
UserAdmin.list_display,
("username", "email", "is_staff", "is_active"),
)

def test_fieldsets(self) -> None:
expected_fieldsets = [
(("Personal info"), {"fields": ("username", "email", "password")}),
(
("Permissions"),
{
"fields": (
"user_permissions",
"groups",
"is_active",
"is_staff",
"is_superuser",
)
},
),
]
self.assertEqual(UserAdmin.fieldsets, expected_fieldsets)

def test_add_fieldsets(self) -> None:
expected_add_fieldsets = (
(
None,
{
"classes": ("wide",),
"fields": ("username", "email", "password1", "password2"),
},
),
)
self.assertEqual(UserAdmin.add_fieldsets, expected_add_fieldsets)