add db prep
[matthijs/upstream/django-ldapdb.git] / ldapdb / tests.py
index 396d2180690ecbae054c956517599dbbabc5ab87..e3c787b008d3db8a7100a73f88943670cbd11cbf 100644 (file)
 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)