From 7a4644723e7b31b2ef8cf499fe846740a62cdcf0 Mon Sep 17 00:00:00 2001 From: jlaine Date: Wed, 19 May 2010 07:06:39 +0000 Subject: [PATCH] start adding unit tests git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@843 e071eeec-0327-468d-9b6a-08194a12b294 --- ldapdb/tests.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ldapdb/tests.py diff --git a/ldapdb/tests.py b/ldapdb/tests.py new file mode 100644 index 0000000..396d218 --- /dev/null +++ b/ldapdb/tests.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# +# django-ldapdb +# Copyright (C) 2009 Bolloré telecom +# See AUTHORS file for a full list of contributors. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +from django.test import TestCase +from django.db.models.sql.where import Constraint, AND, OR + +from ldapdb.models.query import WhereNode + +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)") + + def test_and(self): + where = WhereNode() + where.add((Constraint("cn", "cn", None), 'exact', "foo"), AND) + where.add((Constraint("givenName", "givenName", None), 'exact', "bar"), AND) + self.assertEquals(where.as_sql(), "(&(cn=foo)(givenName=bar))") + + def test_or(self): + where = WhereNode() + where.add((Constraint("cn", "cn", None), 'exact', "foo"), AND) + where.add((Constraint("givenName", "givenName", None), 'exact', "bar"), OR) + self.assertEquals(where.as_sql(), "(|(cn=foo)(givenName=bar))") + -- 2.30.2