g = LdapGroup()
g.name = "foogroup"
g.gid = 1000
- g.usernames = ['foouser']
+ g.usernames = ['foouser', 'baruser']
g.save()
+
+ def test_get(self):
+ self.test_create()
+
+ g = LdapGroup.objects.get(name='foogroup')
+ self.assertEquals(g.name, 'foogroup')
+ self.assertEquals(g.gid, 1000)
+ self.assertEquals(g.usernames, ['foouser', 'baruser'])
class UserTestCase(BaseTestCase):
def test_create(self):
u.uid = 1000
u.username = "foouser"
u.save()
+
+ def test_get(self):
+ self.test_create()
+
+ u = LdapUser.objects.get(username='foouser')
+ self.assertEquals(u.first_name, 'Foo')
+ self.assertEquals(u.last_name, 'User')
+ self.assertEquals(u.full_name, 'Foo User')
+ self.assertEquals(u.group, 1000)
+ self.assertEquals(u.home_directory, '/home/foouser')
+ self.assertEquals(u.uid, 1000)
+ self.assertEquals(u.username, 'foouser')
+
output = []
for dn, attrs in results:
for field in attrs:
- # FIXME : we should not reference the attribute name!
- if field == "member" or field == "memberUid":
- attrs[field] = convert(field, attrs[field], lambda x: x.decode(self.charset))
- else:
- attrs[field] = convert(field, attrs[field][0], lambda x: x.decode(self.charset))
+ attrs[field] = convert(field, attrs[field], lambda x: x.decode(self.charset))
output.append((dn.decode(self.charset), attrs))
return output
import ldapdb
-from ldapdb.models.fields import CharField
+from ldapdb.models.fields import CharField, Integer, ListField
def get_lookup_operator(lookup_type):
if lookup_type == 'gte':
for field in iter(self.model._meta.fields):
if field.attname == 'dn':
row.append(dn)
+ elif isinstance(field, IntegerField):
+ row.append(int(attrs.get(field.db_column, [0])[0]))
+ elif isinstance(field, ListField):
+ row.append(attrs.get(field.db_column, []))
else:
- row.append(attrs.get(field.db_column, None))
+ row.append(attrs.get(field.db_column, [''])[0])
yield row
class QuerySet(BaseQuerySet):