projects
/
matthijs
/
upstream
/
django-ldapdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test admin interface search
[matthijs/upstream/django-ldapdb.git]
/
examples
/
tests.py
diff --git
a/examples/tests.py
b/examples/tests.py
index bca180294e5a8f038a176561aaac6886df88e2d5..08d85b7b6e06dc7d5d5efbaddbcded2eff476d54 100644
(file)
--- a/
examples/tests.py
+++ b/
examples/tests.py
@@
-29,8
+29,9
@@
class BaseTestCase(TestCase):
def setUp(self):
cursor = connection._cursor()
for base in [LdapGroup.base_dn, LdapUser.base_dn]:
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:
try:
cursor.connection.add_s(base, attrs)
except ldap.ALREADY_EXISTS:
@@
-39,9
+40,12
@@
class BaseTestCase(TestCase):
def tearDown(self):
cursor = connection._cursor()
for base in [LdapGroup.base_dn, LdapUser.base_dn]:
def tearDown(self):
cursor = connection._cursor()
for base in [LdapGroup.base_dn, LdapUser.base_dn]:
- results = cursor.connection.search_s(base, ldap.SCOPE_SUBTREE)
- for dn, attrs in reversed(results):
- cursor.connection.delete_s(dn)
+ try:
+ results = cursor.connection.search_s(base, ldap.SCOPE_SUBTREE)
+ for dn, attrs in reversed(results):
+ cursor.connection.delete_s(dn)
+ except ldap.NO_SUCH_OBJECT:
+ pass
class GroupTestCase(BaseTestCase):
def setUp(self):
class GroupTestCase(BaseTestCase):
def setUp(self):
@@
-69,6
+73,12
@@
class GroupTestCase(BaseTestCase):
qs = LdapGroup.objects.filter(name='foogroup')
self.assertEquals(len(qs), 1)
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)
qs = LdapGroup.objects.filter(name='does_not_exist')
self.assertEquals(len(qs), 0)
@@
-152,6
+162,12
@@
class AdminTestCase(BaseTestCase):
g.usernames = ['foouser', 'baruser']
g.save()
g.usernames = ['foouser', 'baruser']
g.save()
+ g = LdapGroup()
+ g.name = "bargroup"
+ g.gid = 1001
+ g.usernames = ['zoouser', 'baruser']
+ g.save()
+
u = LdapUser()
u.first_name = "Foo"
u.last_name = "User"
u = LdapUser()
u.first_name = "Foo"
u.last_name = "User"
@@
-179,6
+195,10
@@
class AdminTestCase(BaseTestCase):
self.assertContains(response, "foogroup")
self.assertContains(response, "1000")
self.assertContains(response, "foogroup")
self.assertContains(response, "1000")
+ def test_group_search(self):
+ response = self.client.get('/admin/examples/ldapgroup/?q=foo')
+ self.assertContains(response, "foogroup")
+
def test_user_list(self):
response = self.client.get('/admin/examples/ldapuser/')
self.assertContains(response, "Ldap users")
def test_user_list(self):
response = self.client.get('/admin/examples/ldapuser/')
self.assertContains(response, "Ldap users")