[CalendarServer-changes] [6812] CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory .py

source_changes at macosforge.org source_changes at macosforge.org
Thu Jan 27 06:08:06 PST 2011


Revision: 6812
          http://trac.macosforge.org/projects/calendarserver/changeset/6812
Author:   sagen at apple.com
Date:     2011-01-27 06:08:06 -0800 (Thu, 27 Jan 2011)
Log Message:
-----------
Deal with not having ldap module installed.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py

Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py	2011-01-27 04:07:57 UTC (rev 6811)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py	2011-01-27 14:08:06 UTC (rev 6812)
@@ -14,68 +14,72 @@
 # limitations under the License.
 ##
 
-from twistedcaldav.directory.ldapdirectory import buildFilter
-from twistedcaldav.test.util import TestCase
+try:
+    from twistedcaldav.directory.ldapdirectory import buildFilter
+except ImportError:
+    print "Skipping because ldap module not installed"
+else:
+    from twistedcaldav.test.util import TestCase
 
-class BuildFilterTestCase(TestCase):
+    class BuildFilterTestCase(TestCase):
 
-    def test_buildFilter(self):
-        mapping = {
-            "fullName" : "cn",
-            "emailAddresses" : "mail",
-            "firstName" : "givenName",
-            "lastName" : "sn",
-        }
+        def test_buildFilter(self):
+            mapping = {
+                "fullName" : "cn",
+                "emailAddresses" : "mail",
+                "firstName" : "givenName",
+                "lastName" : "sn",
+            }
 
-        entries = [
-            {
-                "fields" : [
-                    ("fullName", "mor", True, u"starts-with"),
-                    ("emailAddresses", "mor", True, u"starts-with"),
-                    ("firstName", "mor", True, u"starts-with"),
-                    ("lastName", "mor", True, u"starts-with")
-                ],
-                "operand" : "or",
-                "recordType" : None,
-                "expected" : "(|(cn=mor*)(mail=mor*)(givenName=mor*)(sn=mor*))"
-            },
-            {
-                "fields" : [
-                    ("fullName", "mor", True, u"starts-with"),
-                ],
-                "operand" : "or",
-                "recordType" : None,
-                "expected" : "(cn=mor*)"
-            },
-            {
-                "fields" : [
-                    ("fullName", "mor", True, u"contains"),
-                    ("emailAddresses", "mor", True, u"equals"),
-                    ("invalid", "mor", True, u"starts-with"),
-                ],
-                "operand" : "and",
-                "recordType" : None,
-                "expected" : "(&(cn=*mor*)(mail=mor))"
-            },
-            {
-                "fields" : [
-                    ("invalid", "mor", True, u"contains"),
-                    ("invalid", "mor", True, u"starts-with"),
-                ],
-                "operand" : "and",
-                "recordType" : None,
-                "expected" : None
-            },
-            {
-                "fields" : [ ],
-                "operand" : "and",
-                "recordType" : None,
-                "expected" : None
-            },
-        ]
-        for entry in entries:
-            self.assertEquals(
-                buildFilter(mapping, entry["fields"],
-                    operand=entry["operand"]),
-                entry["expected"]
-            )
+            entries = [
+                {
+                    "fields" : [
+                        ("fullName", "mor", True, u"starts-with"),
+                        ("emailAddresses", "mor", True, u"starts-with"),
+                        ("firstName", "mor", True, u"starts-with"),
+                        ("lastName", "mor", True, u"starts-with")
+                    ],
+                    "operand" : "or",
+                    "recordType" : None,
+                    "expected" : "(|(cn=mor*)(mail=mor*)(givenName=mor*)(sn=mor*))"
+                },
+                {
+                    "fields" : [
+                        ("fullName", "mor", True, u"starts-with"),
+                    ],
+                    "operand" : "or",
+                    "recordType" : None,
+                    "expected" : "(cn=mor*)"
+                },
+                {
+                    "fields" : [
+                        ("fullName", "mor", True, u"contains"),
+                        ("emailAddresses", "mor", True, u"equals"),
+                        ("invalid", "mor", True, u"starts-with"),
+                    ],
+                    "operand" : "and",
+                    "recordType" : None,
+                    "expected" : "(&(cn=*mor*)(mail=mor))"
+                },
+                {
+                    "fields" : [
+                        ("invalid", "mor", True, u"contains"),
+                        ("invalid", "mor", True, u"starts-with"),
+                    ],
+                    "operand" : "and",
+                    "recordType" : None,
+                    "expected" : None
+                },
+                {
+                    "fields" : [ ],
+                    "operand" : "and",
+                    "recordType" : None,
+                    "expected" : None
+                },
+            ]
+            for entry in entries:
+                self.assertEquals(
+                    buildFilter(mapping, entry["fields"],
+                        operand=entry["operand"]),
+                    entry["expected"]
+                )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110127/974ddb62/attachment.html>


More information about the calendarserver-changes mailing list