add tests for Group and GroupManager
This commit is contained in:
parent
7d9224db63
commit
c45e93be03
1 changed files with 35 additions and 1 deletions
|
@ -9,6 +9,7 @@ from osusers.models import (
|
||||||
AdditionalGroup,
|
AdditionalGroup,
|
||||||
DeleteTaskResult,
|
DeleteTaskResult,
|
||||||
Group,
|
Group,
|
||||||
|
GroupTaskResult,
|
||||||
Shadow,
|
Shadow,
|
||||||
User,
|
User,
|
||||||
)
|
)
|
||||||
|
@ -44,8 +45,41 @@ class AdditionalGroupTest(TestCaseWithCeleryTasks):
|
||||||
testsubj.clean()
|
testsubj.clean()
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(OSUSER_MINGID=10000)
|
||||||
|
class GroupManagerTest(TestCase):
|
||||||
|
def test_get_next_gid_first(self):
|
||||||
|
self.assertEqual(Group.objects.get_next_gid(), 10000)
|
||||||
|
|
||||||
|
def test_get_next_gid_second(self):
|
||||||
|
Group.objects.create(gid=10010, groupname='test')
|
||||||
|
self.assertEqual(Group.objects.get_next_gid(), 10011)
|
||||||
|
|
||||||
|
|
||||||
class GroupTest(TestCaseWithCeleryTasks):
|
class GroupTest(TestCaseWithCeleryTasks):
|
||||||
pass
|
def test___str__(self):
|
||||||
|
group = Group.objects.create(gid=10000, groupname='test')
|
||||||
|
self.assertEqual(str(group), 'test (10000)')
|
||||||
|
|
||||||
|
def test_save(self):
|
||||||
|
group = Group(gid=10000, groupname='test')
|
||||||
|
self.assertIs(group.save(), group)
|
||||||
|
taskres = GroupTaskResult.objects.all()
|
||||||
|
self.assertEqual(len(taskres), 1)
|
||||||
|
self.assertEqual(taskres[0].group, group)
|
||||||
|
self.assertEqual(taskres[0].task_name, 'create_ldap_group')
|
||||||
|
|
||||||
|
def test_delete(self):
|
||||||
|
group = Group.objects.create(gid=10000, groupname='test')
|
||||||
|
self.assertEqual(len(Group.objects.all()), 1)
|
||||||
|
self.assertEqual(len(GroupTaskResult.objects.all()), 1)
|
||||||
|
group.delete()
|
||||||
|
self.assertEqual(len(Group.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')
|
||||||
|
self.assertEqual(taskres[0].modeltype, 'group')
|
||||||
|
self.assertEqual(taskres[0].modelname, 'test')
|
||||||
|
|
||||||
|
|
||||||
class ShadowTest(TestCaseWithCeleryTasks):
|
class ShadowTest(TestCaseWithCeleryTasks):
|
||||||
|
|
Loading…
Reference in a new issue