X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=ldapdb%2Ftests.py;h=e3c787b008d3db8a7100a73f88943670cbd11cbf;hb=5b97fccb66efc67de3ce0165528cd454b2245ddc;hp=396d2180690ecbae054c956517599dbbabc5ab87;hpb=7a4644723e7b31b2ef8cf499fe846740a62cdcf0;p=matthijs%2Fupstream%2Fdjango-ldapdb.git diff --git a/ldapdb/tests.py b/ldapdb/tests.py index 396d218..e3c787b 100644 --- a/ldapdb/tests.py +++ b/ldapdb/tests.py @@ -21,14 +21,31 @@ from django.test import TestCase from django.db.models.sql.where import Constraint, AND, OR +from ldapdb.models.fields import CharField from ldapdb.models.query import WhereNode +class FieldTestCase(TestCase): + def test_db_prep(self): + field = CharField() + class WhereTestCase(TestCase): def test_single(self): where = WhereNode() where.add((Constraint("cn", "cn", None), 'exact', "test"), AND) self.assertEquals(where.as_sql(), "(cn=test)") + where = WhereNode() + where.add((Constraint("cn", "cn", None), 'startswith', "test"), AND) + self.assertEquals(where.as_sql(), "(cn=test*)") + + where = WhereNode() + where.add((Constraint("cn", "cn", None), 'endswith', "test"), AND) + self.assertEquals(where.as_sql(), "(cn=*test)") + + where = WhereNode() + where.add((Constraint("cn", "cn", None), 'in', ["foo", "bar"]), AND) + self.assertEquals(where.as_sql(), "(|(cn=foo)(cn=bar))") + def test_and(self): where = WhereNode() where.add((Constraint("cn", "cn", None), 'exact', "foo"), AND)