X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=examples%2Ftests.py;h=465c857a50fcb18d9cfdff8e7a28d7f928bb372d;hp=70d53e3840a76f177475a994f5a785c1c740b0d6;hb=c15d0f62f8b92e9a2c69d9b93ded4cf964ef710c;hpb=9c88ec7a692ff145e42b06d332cdf614efa33c99 diff --git a/examples/tests.py b/examples/tests.py index 70d53e3..465c857 100644 --- a/examples/tests.py +++ b/examples/tests.py @@ -78,6 +78,7 @@ class GroupTestCase(BaseTestCase): self.assertEquals(g.gid, 1000) self.assertEquals(g.usernames, ['foouser', 'baruser']) + # try to get non-existent entry qs = LdapGroup.objects.filter(name='does_not_exist') self.assertEquals(len(qs), 0) @@ -90,6 +91,31 @@ class GroupTestCase(BaseTestCase): self.assertRaises(LdapGroup.DoesNotExist, LdapGroup.objects.get, name='does_not_exist') + def test_order_by(self): + # ascending name + qs = LdapGroup.objects.order_by('name') + self.assertEquals(len(qs), 2) + self.assertEquals(qs[0].name, 'bargroup') + self.assertEquals(qs[1].name, 'foogroup') + + # descending name + qs = LdapGroup.objects.order_by('-name') + self.assertEquals(len(qs), 2) + self.assertEquals(qs[0].name, 'foogroup') + self.assertEquals(qs[1].name, 'bargroup') + + # ascending gid + qs = LdapGroup.objects.order_by('gid') + self.assertEquals(len(qs), 2) + self.assertEquals(qs[0].gid, 1000) + self.assertEquals(qs[1].gid, 1001) + + # descending gid + qs = LdapGroup.objects.order_by('-gid') + self.assertEquals(len(qs), 2) + self.assertEquals(qs[0].gid, 1001) + self.assertEquals(qs[1].gid, 1000) + def test_update(self): g = LdapGroup.objects.get(name='foogroup') @@ -217,6 +243,10 @@ class AdminTestCase(BaseTestCase): self.assertContains(response, "foogroup") self.assertContains(response, "1000") + def test_group_delete(self): + response = self.client.post('/admin/examples/ldapgroup/foogroup/delete/', {'yes': 'post'}) + self.assertRedirects(response, '/admin/examples/ldapgroup/') + def test_group_search(self): response = self.client.get('/admin/examples/ldapgroup/?q=foo') self.assertContains(response, "Ldap groups") @@ -245,3 +275,8 @@ class AdminTestCase(BaseTestCase): response = self.client.get('/admin/examples/ldapuser/foouser/') self.assertContains(response, "foouser") self.assertContains(response, "2000") + + def test_user_delete(self): + response = self.client.post('/admin/examples/ldapuser/foouser/delete/', {'yes': 'post'}) + self.assertRedirects(response, '/admin/examples/ldapuser/') +