add osusers.tests.test_admin.GroupAdminTest
This commit is contained in:
parent
338b575983
commit
266794d447
1 changed files with 26 additions and 0 deletions
|
@ -6,9 +6,11 @@ from django.test.utils import override_settings
|
||||||
from mock import patch, Mock
|
from mock import patch, Mock
|
||||||
|
|
||||||
from osusers.models import (
|
from osusers.models import (
|
||||||
|
Group,
|
||||||
User,
|
User,
|
||||||
)
|
)
|
||||||
from osusers.admin import (
|
from osusers.admin import (
|
||||||
|
GroupAdmin,
|
||||||
PASSWORD_MISMATCH_ERROR,
|
PASSWORD_MISMATCH_ERROR,
|
||||||
UserAdmin,
|
UserAdmin,
|
||||||
UserCreationForm,
|
UserCreationForm,
|
||||||
|
@ -109,3 +111,27 @@ class UserAdminTest(TestCase):
|
||||||
self.assertEqual(len(inlines), len(UserAdmin.inlines))
|
self.assertEqual(len(inlines), len(UserAdmin.inlines))
|
||||||
for index in range(len(inlines)):
|
for index in range(len(inlines)):
|
||||||
self.assertIsInstance(inlines[index], UserAdmin.inlines[index])
|
self.assertIsInstance(inlines[index], UserAdmin.inlines[index])
|
||||||
|
|
||||||
|
|
||||||
|
class GroupAdminTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
site = AdminSite()
|
||||||
|
self.gadmin = GroupAdmin(Group, site)
|
||||||
|
super(GroupAdminTest, self).setUp()
|
||||||
|
|
||||||
|
def test_get_inline_instances_without_object(self):
|
||||||
|
inlines = self.gadmin.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):
|
||||||
|
group = Group.objects.create(gid=1000, groupname='test')
|
||||||
|
inlines = self.gadmin.get_inline_instances(
|
||||||
|
Mock(name='request'), group)
|
||||||
|
self.assertEqual(len(inlines), len(GroupAdmin.inlines))
|
||||||
|
for index in range(len(inlines)):
|
||||||
|
self.assertIsInstance(inlines[index], GroupAdmin.inlines[index])
|
||||||
|
|
Loading…
Reference in a new issue