This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(apps/users): fix some tests for user app
- Loading branch information
1 parent
22e98f6
commit 38f3091
Showing
2 changed files
with
22 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from django.test import TestCase | ||
from django.utils.translation import gettext as _ | ||
|
||
from apps.users.admin import UserAdmin | ||
from apps.users.models import User | ||
|
@@ -19,6 +20,7 @@ def test_create_user(self) -> None: | |
email="[email protected]", | ||
password="testpassword", | ||
) | ||
|
||
self.assertEqual(user.email, "[email protected]") | ||
self.assertEqual(user.username, "testuser") | ||
self.assertFalse(user.is_staff) | ||
|
@@ -30,6 +32,7 @@ def test_create_superuser(self) -> None: | |
email="[email protected]", | ||
password="adminpassword", | ||
) | ||
|
||
self.assertEqual(superuser.email, "[email protected]") | ||
self.assertEqual(superuser.username, "adminuser") | ||
self.assertTrue(superuser.is_staff) | ||
|
@@ -38,16 +41,25 @@ def test_create_superuser(self) -> None: | |
|
||
class UserAdminTestCase(TestCase): | ||
def test_list_display(self) -> None: | ||
self.assertEqual( | ||
UserAdmin.list_display, | ||
("username", "email", "is_staff", "is_active"), | ||
) | ||
list_display = UserAdmin.list_display | ||
expected = ("username", "email", "is_staff", "is_active") | ||
|
||
self.assertEqual(list_display, expected) | ||
|
||
def test_list_filter(self) -> None: | ||
list_filter = UserAdmin.list_filter | ||
expected = ("is_staff", "is_superuser", "is_active", "groups") | ||
|
||
self.assertEqual(list_filter, expected) | ||
|
||
def test_fieldsets(self) -> None: | ||
expected_fieldsets = [ | ||
(("Personal info"), {"fields": ("username", "email", "password")}), | ||
expected = [ | ||
( | ||
_("Personal info"), | ||
{"fields": ("username", "email", "password")}, | ||
), | ||
( | ||
("Permissions"), | ||
_("Permissions"), | ||
{ | ||
"fields": ( | ||
"user_permissions", | ||
|
@@ -59,7 +71,8 @@ def test_fieldsets(self) -> None: | |
}, | ||
), | ||
] | ||
self.assertEqual(UserAdmin.fieldsets, expected_fieldsets) | ||
|
||
self.assertEqual(UserAdmin.fieldsets, expected) | ||
|
||
def test_add_fieldsets(self) -> None: | ||
expected_add_fieldsets = ( | ||
|
@@ -71,4 +84,5 @@ def test_add_fieldsets(self) -> None: | |
}, | ||
), | ||
) | ||
|
||
self.assertEqual(UserAdmin.add_fieldsets, expected_add_fieldsets) |