add osusers.tests.test_admin.UserAdminTest
This commit is contained in:
parent
3db6b99a00
commit
09f72fc091
1 changed files with 43 additions and 0 deletions
|
@ -10,6 +10,7 @@ from osusers.models import (
|
||||||
)
|
)
|
||||||
from osusers.admin import (
|
from osusers.admin import (
|
||||||
PASSWORD_MISMATCH_ERROR,
|
PASSWORD_MISMATCH_ERROR,
|
||||||
|
UserAdmin,
|
||||||
UserCreationForm,
|
UserCreationForm,
|
||||||
UserTaskResultInline,
|
UserTaskResultInline,
|
||||||
)
|
)
|
||||||
|
@ -64,3 +65,45 @@ class UserCreationFormTest(TestCase):
|
||||||
user = form.save()
|
user = form.save()
|
||||||
self.assertIsNotNone(user)
|
self.assertIsNotNone(user)
|
||||||
self.assertEqual(User.objects.get(pk=user.uid), user)
|
self.assertEqual(User.objects.get(pk=user.uid), user)
|
||||||
|
|
||||||
|
|
||||||
|
class UserAdminTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
site = AdminSite()
|
||||||
|
self.uadmin = UserAdmin(User, site)
|
||||||
|
super(UserAdminTest, self).setUp()
|
||||||
|
|
||||||
|
def test_get_form_without_object(self):
|
||||||
|
form = self.uadmin.get_form(Mock(name='request'))
|
||||||
|
self.assertEqual(
|
||||||
|
form.Meta.fields,
|
||||||
|
['password1', 'password2']
|
||||||
|
)
|
||||||
|
|
||||||
|
@override_settings(
|
||||||
|
CELERY_ALWAYS_EAGER=True,
|
||||||
|
CELERY_CACHE_BACKEND='memory',
|
||||||
|
BROKER_BACKEND='memory'
|
||||||
|
)
|
||||||
|
def test_get_form_with_object(self):
|
||||||
|
user = User.objects.create_user()
|
||||||
|
form = self.uadmin.get_form(Mock(name='request'), user)
|
||||||
|
self.assertEqual(
|
||||||
|
form.Meta.fields,
|
||||||
|
['username', 'group', 'gecos', 'homedir', 'shell', 'uid']
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_get_inline_instances_without_object(self):
|
||||||
|
inlines = self.uadmin.get_inline_instances(Mock(name='request'))
|
||||||
|
self.assertEqual(inlines, [])
|
||||||
|
|
||||||
|
@override_settings(
|
||||||
|
CELERY_ALWAYS_EAGER=True,
|
||||||
|
CELERY_CACHE_BACKEND='memory',
|
||||||
|
BROKER_BACKEND='memory'
|
||||||
|
)
|
||||||
|
def test_get_inline_instances_with_object(self):
|
||||||
|
user = User.objects.create_user()
|
||||||
|
inlines = self.uadmin.get_inline_instances(
|
||||||
|
Mock(name='request'), user)
|
||||||
|
self.assertEqual(len(inlines), len(UserAdmin.inlines))
|
||||||
|
|
Loading…
Reference in a new issue