X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=examples%2Ftests.py;h=f99ea2e39ad4c2c508b7d192eaf049932f3c7c38;hp=e96ad90e9a41346bfa104f86bd528b7aeecc6caa;hb=86f79b1135e0983d0a48e211685c57ce76ea09e0;hpb=5581ef499d94127504e076f540e71ef412fd88df diff --git a/examples/tests.py b/examples/tests.py index e96ad90..f99ea2e 100644 --- a/examples/tests.py +++ b/examples/tests.py @@ -133,6 +133,30 @@ class GroupTestCase(BaseTestCase): qs = LdapGroup.objects.all() self.assertEquals(len(qs), 0) + def test_slice(self): + qs = LdapGroup.objects.all() + objs = list(qs) + self.assertEquals(len(objs), 3) + self.assertEquals(objs[0].gid, 1000) + self.assertEquals(objs[1].gid, 1001) + self.assertEquals(objs[2].gid, 1002) + + qs = LdapGroup.objects.all() + objs = qs[:2] + for o in objs: + return + print objs + self.assertEquals(len(objs), 2) + self.assertEquals(objs[0].gid, 1000) + self.assertEquals(objs[1].gid, 1001) + return + + qs = LdapGroup.objects.all() + objs = qs[1:] + self.assertEquals(len(objs), 2) + self.assertEquals(objs[0].gid, 1001) + self.assertEquals(objs[1].gid, 1002) + def test_update(self): g = LdapGroup.objects.get(name='foogroup')