add osusers.tests.test_admin.GroupAdminTest

This commit is contained in:
Jan Dittberner 2014-06-01 22:53:38 +02:00
parent 338b575983
commit 266794d447

View file

@ -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])