rework tests
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 24 May 2010 08:37:28 +0000 (08:37 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 24 May 2010 08:37:28 +0000 (08:37 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@864 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/query.py
ldapdb/tests.py

index a8c614f7ccfe6a2ee487ac35b38bb474951efa0c..b8e4897a645e1132424c1b735aff28928235408d 100644 (file)
@@ -81,15 +81,14 @@ class WhereNode(BaseWhereNode):
             if isinstance(item, WhereNode):
                 bits.append(item.as_sql())
                 continue
-            constraint, x, y, values = item
+            constraint, lookup_type, y, values = item
+            comp = get_lookup_operator(lookup_type)
             if hasattr(constraint, "col"):
                 # django 1.2
-                comp = get_lookup_operator(constraint.lookup_type)
                 clause = "(%s%s%s)" % (constraint.col, comp, values)
             else:
                 # django 1.1
                 (table, column, db_type) = constraint
-                comp = get_lookup_operator(x)
                 equal_bits = [ "(%s%s%s)" % (column, comp, value) for value in values ]
                 if len(equal_bits) == 1:
                     clause = equal_bits[0]
index 10b7c5bd347f02db01691a0789ce7e557b8987cb..b102a3ef2670cf096575b30800a0aedfb60236c9 100644 (file)
@@ -33,7 +33,7 @@ class WhereTestCase(TestCase):
         self.assertEquals(escape_ldap_filter('foo\\bar'), 'foo\\5cbar')
         self.assertEquals(escape_ldap_filter('foo\\bar*wiz'), 'foo\\5cbar\\2awiz')
 
-    def test_char_field(self):
+    def test_char_field_exact(self):
         where = WhereNode()
         where.add((Constraint("cn", "cn", CharField()), 'exact', "test"), AND)
         self.assertEquals(where.as_sql(), "(cn=test)")
@@ -42,6 +42,7 @@ class WhereTestCase(TestCase):
         where.add((Constraint("cn", "cn", CharField()), 'exact', "(test)"), AND)
         self.assertEquals(where.as_sql(), "(cn=\\28test\\29)")
 
+    def test_char_field_in(self):
         where = WhereNode()
         where.add((Constraint("cn", "cn", CharField()), 'in', ["foo", "bar"]), AND)
         self.assertEquals(where.as_sql(), "(|(cn=foo)(cn=bar))")
@@ -50,6 +51,7 @@ class WhereTestCase(TestCase):
         where.add((Constraint("cn", "cn", CharField()), 'in', ["(foo)", "(bar)"]), AND)
         self.assertEquals(where.as_sql(), "(|(cn=\\28foo\\29)(cn=\\28bar\\29))")
 
+    def test_char_field_startswith(self):
         where = WhereNode()
         where.add((Constraint("cn", "cn", CharField()), 'startswith', "test"), AND)
         self.assertEquals(where.as_sql(), "(cn=test*)")
@@ -58,10 +60,7 @@ class WhereTestCase(TestCase):
         where.add((Constraint("cn", "cn", CharField()), 'endswith', "test"), AND)
         self.assertEquals(where.as_sql(), "(cn=*test)")
 
-        where = WhereNode()
-        where.add((Constraint("cn", "cn", CharField()), 'in', ["foo", "bar"]), AND)
-        self.assertEquals(where.as_sql(), "(|(cn=foo)(cn=bar))")
-
+    def test_char_field_contains(self):
         where = WhereNode()
         where.add((Constraint("cn", "cn", CharField()), 'contains', "test"), AND)
         self.assertEquals(where.as_sql(), "(cn=*test*)")