[CalendarServer-changes] [6338] CalDAVTester/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 22 12:48:53 PDT 2010


Revision: 6338
          http://trac.macosforge.org/projects/calendarserver/changeset/6338
Author:   cdaboo at apple.com
Date:     2010-09-22 12:48:52 -0700 (Wed, 22 Sep 2010)
Log Message:
-----------
Fix multi-XML element in property testing cases.

Modified Paths:
--------------
    CalDAVTester/trunk/scripts/tests/CalDAV/availability.xml
    CalDAVTester/trunk/scripts/tests/CalDAV/calendaruserproxy.xml
    CalDAVTester/trunk/scripts/tests/CalDAV/copymove.xml
    CalDAVTester/trunk/scripts/tests/CalDAV/dropbox.xml
    CalDAVTester/trunk/verifiers/propfindItems.py
    CalDAVTester/trunk/verifiers/xmlElementMatch.py

Modified: CalDAVTester/trunk/scripts/tests/CalDAV/availability.xml
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/availability.xml	2010-09-22 14:52:44 UTC (rev 6337)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/availability.xml	2010-09-22 19:48:52 UTC (rev 6338)
@@ -97,10 +97,13 @@
 					<filepath>Resource/CalDAV/availability/1.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set$<comp name="VEVENT" xmlns="urn:ietf:params:xml:ns:caldav"/><comp name="VTODO" xmlns="urn:ietf:params:xml:ns:caldav"/><comp name="VTIMEZONE" xmlns="urn:ietf:params:xml:ns:caldav"/><comp name="VFREEBUSY" xmlns="urn:ietf:params:xml:ns:caldav"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set/{urn:ietf:params:xml:ns:caldav}comp[@name="VEVENT"]</value>
+						<value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set/{urn:ietf:params:xml:ns:caldav}comp[@name="VTODO"]</value>
+						<value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set/{urn:ietf:params:xml:ns:caldav}comp[@name="VTIMEZONE"]</value>
+						<value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set/{urn:ietf:params:xml:ns:caldav}comp[@name="VFREEBUSY"]</value>
 					</arg>
 				</verify>
 			</request>

Modified: CalDAVTester/trunk/scripts/tests/CalDAV/calendaruserproxy.xml
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/calendaruserproxy.xml	2010-09-22 14:52:44 UTC (rev 6337)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/calendaruserproxy.xml	2010-09-22 19:48:52 UTC (rev 6338)
@@ -89,10 +89,12 @@
 					<filepath>Resource/CalDAV/calendaruserproxy/1.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<D:principal xmlns:D="DAV:"/><D:collection xmlns:D="DAV:"/><CS:calendar-proxy-read xmlns:CS="http://calendarserver.org/ns/"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}principal</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}calendar-proxy-read</value>
 					</arg>
 				</verify>
 			</request>
@@ -107,10 +109,12 @@
 					<filepath>Resource/CalDAV/calendaruserproxy/1.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<D:principal xmlns:D="DAV:"/><D:collection xmlns:D="DAV:"/><CS:calendar-proxy-write xmlns:CS="http://calendarserver.org/ns/"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}principal</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}calendar-proxy-write</value>
 					</arg>
 				</verify>
 			</request>

Modified: CalDAVTester/trunk/scripts/tests/CalDAV/copymove.xml
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/copymove.xml	2010-09-22 14:52:44 UTC (rev 6337)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/copymove.xml	2010-09-22 19:48:52 UTC (rev 6338)
@@ -505,10 +505,11 @@
 					<filepath>Resource/CalDAV/copymove/7.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<collection xmlns="DAV:"/><calendar xmlns="urn:ietf:params:xml:ns:caldav"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value>
 					</arg>
 				</verify>
 			</request>
@@ -535,10 +536,11 @@
 					<filepath>Resource/CalDAV/copymove/7.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<collection xmlns="DAV:"/><calendar xmlns="urn:ietf:params:xml:ns:caldav"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value>
 					</arg>
 				</verify>
 			</request>
@@ -564,10 +566,11 @@
 					<filepath>Resource/CalDAV/copymove/7.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<D:collection xmlns:D="DAV:"/><CS:calendar xmlns:CS="urn:ietf:params:xml:ns:caldav"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value>
 					</arg>
 				</verify>
 			</request>
@@ -594,10 +597,11 @@
 					<filepath>Resource/CalDAV/copymove/7.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<D:collection xmlns:D="DAV:"/><CS:calendar xmlns:CS="urn:ietf:params:xml:ns:caldav"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value>
 					</arg>
 				</verify>
 			</request>

Modified: CalDAVTester/trunk/scripts/tests/CalDAV/dropbox.xml
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/dropbox.xml	2010-09-22 14:52:44 UTC (rev 6337)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/dropbox.xml	2010-09-22 19:48:52 UTC (rev 6338)
@@ -77,10 +77,11 @@
 					<filepath>Resource/CalDAV/dropbox/2.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<collection xmlns="DAV:"/><dropbox-home xmlns="http://calendarserver.org/ns/"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}dropbox-home</value>
 					</arg>
 				</verify>
 			</request>
@@ -116,10 +117,11 @@
 					<filepath>Resource/CalDAV/dropbox/2.xml</filepath>
 				</data>
 				<verify>
-					<callback>propfindItems</callback>
+					<callback>xmlElementMatch</callback>
 					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{DAV:}resourcetype$<collection xmlns="DAV:"/><dropbox xmlns="http://calendarserver.org/ns/"/>]]></value>
+						<name>exists</name>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+						<value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}dropbox</value>
 					</arg>
 				</verify>
 			</request>

Modified: CalDAVTester/trunk/verifiers/propfindItems.py
===================================================================
--- CalDAVTester/trunk/verifiers/propfindItems.py	2010-09-22 14:52:44 UTC (rev 6337)
+++ CalDAVTester/trunk/verifiers/propfindItems.py	2010-09-22 19:48:52 UTC (rev 6338)
@@ -53,13 +53,11 @@
         def normalizeXML(value):
             
             if value[0] == '<':
-                value = "<CDTdummy>" + value + "</CDTdummy>"
                 try:
                     tree = ElementTree(file=StringIO(value))
                 except Exception:
                     return False, "           Could not parse XML value: %s\n" % (value,)
                 value = tostring(tree.getroot())
-                value = value.replace("<CDTdummy>", "").replace("</CDTdummy>", "")
             return value
 
         # Get property arguments and split on $ delimited for name, value tuples

Modified: CalDAVTester/trunk/verifiers/xmlElementMatch.py
===================================================================
--- CalDAVTester/trunk/verifiers/xmlElementMatch.py	2010-09-22 14:52:44 UTC (rev 6337)
+++ CalDAVTester/trunk/verifiers/xmlElementMatch.py	2010-09-22 19:48:52 UTC (rev 6338)
@@ -65,37 +65,47 @@
                 root_path, child_path = actual_path.split('/', 1)
                 if tree.getroot().tag != root_path:
                     resulttxt += "        Items not returned in XML for %s\n" % (path,)
-                node = tree.find(child_path)
+                nodes = tree.findall(child_path)
             else:
                 root_path = actual_path
                 child_path = None
-                node = tree.getroot()
+                nodes = (tree.getroot(),)
             
-            if node is None:
+            if len(nodes) == 0:
                 resulttxt += "        Items not returned in XML for %s\n" % (path,)
                 result = False
                 continue
             if tests:
                 tests = [item[:-1] for item in tests.split('[')]
                 for test in tests:
-                    if test[0] == '@':
-                        if '=' in test:
-                            attr, value = test[1:].split('=')
-                            value = value[1:-1]
-                        else:
-                            attr = test[1:]
-                            value = None
-                        if attr not in node.keys():
-                            resulttxt += "        Missing attribute returned in XML for %s\n" % (path,)
-                            result = False
+                    for node in nodes:
+                        
+                        def _doTest():
+                            result = None
+                            if test[0] == '@':
+                                if '=' in test:
+                                    attr, value = test[1:].split('=')
+                                    value = value[1:-1]
+                                else:
+                                    attr = test[1:]
+                                    value = None
+                                if attr not in node.keys():
+                                    result = "        Missing attribute returned in XML for %s\n" % (path,)
+                                if value is not None and node.get(attr) != value:
+                                    result = "        Incorrect attribute value returned in XML for %s\n" % (path,)
+                            elif test[0] == '=':
+                                if node.text != test[1:]:
+                                    result = "        Incorrect value returned in XML for %s\n" % (path,)
+                            return result
+                        
+                        testresult = _doTest()
+                        if testresult is None:
                             break
-                        if value is not None and node.get(attr) != value:
-                            resulttxt += "        Incorrect attribute value returned in XML for %s\n" % (path,)
-                            result = False
-                            break
-                    elif test[0] == '=':
-                        if node.text != test[1:]:
-                            resulttxt += "        Incorrect value returned in XML for %s\n" % (path,)
+                    if testresult is not None:
+                        resulttxt += testresult
+                        result = False
+                        break
+                         
                             
         for path in notexists:
             if tree.find(path) is not None:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100922/e8012cc0/attachment-0001.html>


More information about the calendarserver-changes mailing list