[CalendarServer-changes] [13654] CalendarServer/branches/users/sagen/recordtypes

source_changes at macosforge.org source_changes at macosforge.org
Wed Jun 18 14:02:14 PDT 2014


Revision: 13654
          http://trac.calendarserver.org//changeset/13654
Author:   sagen at apple.com
Date:     2014-06-18 14:02:13 -0700 (Wed, 18 Jun 2014)
Log Message:
-----------
Handle recordsMatchingFields with a single field

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/recordtypes/contrib/od/test/test_live.py
    CalendarServer/branches/users/sagen/recordtypes/txdav/who/directory.py

Modified: CalendarServer/branches/users/sagen/recordtypes/contrib/od/test/test_live.py
===================================================================
--- CalendarServer/branches/users/sagen/recordtypes/contrib/od/test/test_live.py	2014-06-18 20:27:26 UTC (rev 13653)
+++ CalendarServer/branches/users/sagen/recordtypes/contrib/od/test/test_live.py	2014-06-18 21:02:13 UTC (rev 13654)
@@ -441,7 +441,7 @@
 
         @onlyIfPopulated
         @inlineCallbacks
-        def test_recordsMatchingFieldsNoRecordType(self):
+        def test_recordsMatchingMultipleFieldsNoRecordType(self):
             self.calService = CalOpenDirectoryService()
             fields = (
                 (u"fullNames", u"be", MatchFlags.caseInsensitive, MatchType.contains),
@@ -464,6 +464,30 @@
 
         @onlyIfPopulated
         @inlineCallbacks
+        def test_recordsMatchingSingleFieldNoRecordType(self):
+            self.calService = CalOpenDirectoryService()
+            fields = (
+                (u"fullNames", u"test", MatchFlags.caseInsensitive, MatchType.contains),
+            )
+            records = (yield self.calService.recordsMatchingFields(
+                fields, operand=Operand.AND, recordType=None
+            ))
+            print("final records", records)
+            self.verifyResults(
+                records,
+                [
+                    "odtestgroupbetty", "odtestgroupalbert",
+                    "odtestbetty", "odtestalbert", "anotherodtestalbert",
+                    "odtestamanda",
+                ],
+                [
+                    "nobody",
+                ]
+            )
+
+
+        @onlyIfPopulated
+        @inlineCallbacks
         def test_recordsMatchingFieldsWithRecordType(self):
             self.calService = CalOpenDirectoryService()
             fields = (

Modified: CalendarServer/branches/users/sagen/recordtypes/txdav/who/directory.py
===================================================================
--- CalendarServer/branches/users/sagen/recordtypes/txdav/who/directory.py	2014-06-18 20:27:26 UTC (rev 13653)
+++ CalendarServer/branches/users/sagen/recordtypes/txdav/who/directory.py	2014-06-18 21:02:13 UTC (rev 13654)
@@ -234,7 +234,10 @@
             )
             subExpressions.append(subExpression)
 
-        expression = CompoundExpression(subExpressions, operand)
+        if len(subExpressions) == 1:
+            expression = subExpressions[0]
+        else:
+            expression = CompoundExpression(subExpressions, operand)
 
         if recordType is not None:
             recordTypes = [recordType]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140618/0679d4b4/attachment.html>


More information about the calendarserver-changes mailing list