improve unit tests
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 31 May 2010 17:05:16 +0000 (17:05 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 31 May 2010 17:05:16 +0000 (17:05 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@896 e071eeec-0327-468d-9b6a-08194a12b294

examples/tests.py

index bca180294e5a8f038a176561aaac6886df88e2d5..c677c81045ef1f40d47bc14cf4a9a1bd698c1567 100644 (file)
@@ -29,8 +29,9 @@ class BaseTestCase(TestCase):
     def setUp(self):
         cursor = connection._cursor()
         for base in [LdapGroup.base_dn, LdapUser.base_dn]:
-            ou = base.split(',')[0].split('=')[1]
-            attrs = [('objectClass', ['top', 'organizationalUnit']), ('ou', [ou])]
+            rdn = base.split(',')[0]
+            key, val = rdn.split('=')
+            attrs = [('objectClass', ['top', 'organizationalUnit']), (key, [val])]
             try:
                 cursor.connection.add_s(base, attrs)
             except ldap.ALREADY_EXISTS:
@@ -69,6 +70,12 @@ class GroupTestCase(BaseTestCase):
         qs = LdapGroup.objects.filter(name='foogroup')
         self.assertEquals(len(qs), 1)
 
+        g = qs[0]
+        self.assertEquals(g.dn, 'cn=foogroup,ou=groups,dc=nodomain')
+        self.assertEquals(g.name, 'foogroup')
+        self.assertEquals(g.gid, 1000)
+        self.assertEquals(g.usernames, ['foouser', 'baruser'])
+
         qs = LdapGroup.objects.filter(name='does_not_exist')
         self.assertEquals(len(qs), 0)