fix some test issues

This commit is contained in:
Jan Dittberner 2015-01-22 00:19:16 +01:00
parent 680f091cba
commit d4f68a155c
4 changed files with 3 additions and 43 deletions

View file

@ -160,7 +160,7 @@ class MailBoxAdminTest(TestCase):
form = self.mbadmin.get_form(Mock) form = self.mbadmin.get_form(Mock)
self.assertEqual( self.assertEqual(
form.Meta.fields, form.Meta.fields,
['username', 'password1', 'password2'] ['osuser', 'password1', 'password2']
) )
@override_settings( @override_settings(

View file

@ -6,17 +6,14 @@ 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 (
DeleteTaskResult,
Group, Group,
User, User,
) )
from osusers.admin import ( from osusers.admin import (
DeleteTaskResultAdmin,
GroupAdmin, GroupAdmin,
PASSWORD_MISMATCH_ERROR, PASSWORD_MISMATCH_ERROR,
UserAdmin, UserAdmin,
UserCreationForm, UserCreationForm,
UserTaskResultInline,
) )
@ -85,7 +82,7 @@ class UserAdminTest(TestCase):
form = self.uadmin.get_form(Mock(name='request')) form = self.uadmin.get_form(Mock(name='request'))
self.assertEqual( self.assertEqual(
form.Meta.fields, form.Meta.fields,
['password1', 'password2'] ['customer', 'password1', 'password2']
) )
@override_settings( @override_settings(
@ -103,7 +100,7 @@ class UserAdminTest(TestCase):
def test_get_inline_instances_without_object(self): def test_get_inline_instances_without_object(self):
inlines = self.uadmin.get_inline_instances(Mock(name='request')) inlines = self.uadmin.get_inline_instances(Mock(name='request'))
self.assertEqual(inlines, []) self.assertEqual(len(inlines), 2)
@override_settings( @override_settings(
CELERY_ALWAYS_EAGER=True, CELERY_ALWAYS_EAGER=True,

View file

@ -12,12 +12,9 @@ from passlib.hash import sha512_crypt
from osusers.models import ( from osusers.models import (
CANNOT_USE_PRIMARY_GROUP_AS_ADDITIONAL, CANNOT_USE_PRIMARY_GROUP_AS_ADDITIONAL,
AdditionalGroup, AdditionalGroup,
DeleteTaskResult,
Group, Group,
GroupTaskResult,
Shadow, Shadow,
User, User,
UserTaskResult,
) )
@ -62,13 +59,7 @@ class AdditionalGroupTest(TestCaseWithCeleryTasks):
def test_delete(self): def test_delete(self):
group2 = Group.objects.create(groupname='test2', gid=1001) group2 = Group.objects.create(groupname='test2', gid=1001)
addgroup = AdditionalGroup.objects.create(user=self.user, group=group2) addgroup = AdditionalGroup.objects.create(user=self.user, group=group2)
DeleteTaskResult.objects.all().delete()
addgroup.delete() addgroup.delete()
taskres = DeleteTaskResult.objects.all()
self.assertTrue(len(taskres), 1)
self.assertEqual(taskres[0].task_name, 'remove_ldap_user_from_group')
self.assertEqual(taskres[0].modeltype, 'usergroup')
self.assertEqual(taskres[0].modelname, 'test (1000) in test2 (1001)')
self.assertEqual(len(AdditionalGroup.objects.all()), 0) self.assertEqual(len(AdditionalGroup.objects.all()), 0)
def test___str__(self): def test___str__(self):
@ -107,12 +98,6 @@ class GroupTest(TestCaseWithCeleryTasks):
group.delete() group.delete()
self.assertEqual(len(Group.objects.all()), 0) self.assertEqual(len(Group.objects.all()), 0)
self.assertEqual(len(GroupTaskResult.objects.all()), 0) self.assertEqual(len(GroupTaskResult.objects.all()), 0)
taskres = DeleteTaskResult.objects.all()
self.assertEqual(len(taskres), 1)
self.assertEqual(taskres[0].task_name,
'delete_ldap_group_if_empty')
self.assertEqual(taskres[0].modeltype, 'group')
self.assertEqual(taskres[0].modelname, 'test')
class ShadowManagerTest(TestCaseWithCeleryTasks): class ShadowManagerTest(TestCaseWithCeleryTasks):

View file

@ -1,22 +0,0 @@
from django.test import TestCase
from osusers.tasks import LdapRouter
class LdapRouterTest(TestCase):
def setUp(self):
self.router = LdapRouter()
super(LdapRouterTest, self).setUp()
def test_ldap_tasks_are_routed_to_ldap_queue(self):
route = self.router.route_for_task(
'some_ldap_task')
self.assertEqual(
route,
{'exchange': 'ldap',
'exchange_type': 'direct',
'queue': 'ldap'})
def test_non_ldap_tasks_are_routed_to_default(self):
self.assertIsNone(
self.router.route_for_task('other'))