X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=examples%2Ftests.py;h=e1088520fb65afc7fbcc7859da6632ae15fc572a;hb=4abdee082b2cb5697cf0e6436df871a36cccdbe6;hp=70d53e3840a76f177475a994f5a785c1c740b0d6;hpb=9c88ec7a692ff145e42b06d332cdf614efa33c99;p=matthijs%2Fupstream%2Fdjango-ldapdb.git diff --git a/examples/tests.py b/examples/tests.py index 70d53e3..e108852 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,37 @@ 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_bulk_delete(self): + LdapGroup.objects.all().delete() + + qs = LdapGroup.objects.all() + self.assertEquals(len(qs), 0) + def test_update(self): g = LdapGroup.objects.get(name='foogroup') @@ -217,6 +249,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 +281,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/') +