From 8ce4d769e2f75d829afbcc761b01c06a6219e3e0 Mon Sep 17 00:00:00 2001 From: jlaine Date: Mon, 31 May 2010 18:37:26 +0000 Subject: [PATCH] test ordering git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@904 e071eeec-0327-468d-9b6a-08194a12b294 --- examples/tests.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/examples/tests.py b/examples/tests.py index 70d53e3..533df5c 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') -- 2.30.2