[CalendarServer-changes] [13559] CalendarServer/trunk/txdav/dps/test/test_json.py

source_changes at macosforge.org source_changes at macosforge.org
Thu May 29 12:02:22 PDT 2014


Revision: 13559
          http://trac.calendarserver.org//changeset/13559
Author:   wsanchez at apple.com
Date:     2014-05-29 12:02:22 -0700 (Thu, 29 May 2014)
Log Message:
-----------
Add test_compoundExpressionAsJSON_expressions

Modified Paths:
--------------
    CalendarServer/trunk/txdav/dps/test/test_json.py

Modified: CalendarServer/trunk/txdav/dps/test/test_json.py
===================================================================
--- CalendarServer/trunk/txdav/dps/test/test_json.py	2014-05-29 18:44:32 UTC (rev 13558)
+++ CalendarServer/trunk/txdav/dps/test/test_json.py	2014-05-29 19:02:22 UTC (rev 13559)
@@ -20,10 +20,10 @@
 
 from twext.who.idirectory import FieldName
 from twext.who.expression import MatchExpression, MatchType, MatchFlags
-# from twext.who.expression import CompoundExpression, Operand
+from twext.who.expression import CompoundExpression, Operand
 
 from ..json import (
-    matchExpressionAsJSON,  # compoundExpressionAsJSON,
+    matchExpressionAsJSON, compoundExpressionAsJSON,
     # expressionAsJSON, expressionAsJSONText,
     # matchExpressionFromJSON, compoundExpressionFromJSON,
     # expressionFromJSON, expressionFromJSONText,
@@ -120,3 +120,29 @@
             }
 
             self.assertEquals(json, expected)
+
+
+    def test_compoundExpressionAsJSON_expressions(self):
+        """
+        L{compoundExpressionAsJSON} with 0, 1 and 2 sub-expressions.
+        """
+        for uids in (
+            (), (u"UID1",), (u"UID1", u"UID2"),
+        ):
+            subExpressions = [
+                MatchExpression(FieldName.uid, uid) for uid in uids
+            ]
+            subExpressionsText = [
+                matchExpressionAsJSON(e) for e in subExpressions
+            ]
+
+            expression = CompoundExpression(subExpressions, Operand.AND)
+            json = compoundExpressionAsJSON(expression)
+
+            expected = {
+                'type': 'CompoundExpression',
+                'expressions': subExpressionsText,
+                'operand': 'AND',
+            }
+
+            self.assertEquals(json, expected)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140529/5e1d84ad/attachment.html>


More information about the calendarserver-changes mailing list