[CalendarServer-changes] [10099] CalDAVTester/branches/users/cdaboo/managed-attachments

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 28 10:38:02 PST 2012


Revision: 10099
          http://trac.calendarserver.org//changeset/10099
Author:   cdaboo at apple.com
Date:     2012-11-28 10:38:02 -0800 (Wed, 28 Nov 2012)
Log Message:
-----------
Add option to grab the count of child resources into a substitution variable and enable the verifiers that check counts
to use that variable in an eval() statement to support tests that check if the count increases or decreases without
having to know what the total number of resources might be.

Modified Paths:
--------------
    CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/caldavtest.dtd
    CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/sharing-multiple.xml
    CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CardDAV/caldavtest.dtd
    CalDAVTester/branches/users/cdaboo/managed-attachments/src/caldavtest.py
    CalDAVTester/branches/users/cdaboo/managed-attachments/src/request.py
    CalDAVTester/branches/users/cdaboo/managed-attachments/src/xmlDefs.py
    CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/multistatusItems.py
    CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/propfindItems.py

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/caldavtest.dtd
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/caldavtest.dtd	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/caldavtest.dtd	2012-11-28 18:38:02 UTC (rev 10099)
@@ -30,7 +30,7 @@
 	<!ELEMENT pause EMPTY>
 
 	<!ELEMENT request (require-feature?, exclude-feature?, method, ruri*, header*, data?, verify*,
-						graburi?, grabheader*, grabproperty*, grabelement*, grabcalproperty*, grabcalparameter*)>
+						graburi?, grabcount?, grabheader*, grabproperty*, grabelement*, grabcalproperty*, grabcalparameter*)>
 		<!ATTLIST request auth (yes|no) "yes"
 						 user CDATA ""
 						 pswd CDATA ""
@@ -55,6 +55,8 @@
 		
 		<!ELEMENT graburi (#PCDATA)>
 
+		<!ELEMENT grabcount (#PCDATA)>
+
 		<!ELEMENT grabheader (name, variable)>
 	
 		<!ELEMENT grabproperty (property, variable)>

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/sharing-multiple.xml
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/sharing-multiple.xml	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CalDAV/sharing-multiple.xml	2012-11-28 18:38:02 UTC (rev 10099)
@@ -53,6 +53,25 @@
 	
 	<test-suite name='Send new invite #1'>
 		<test name='1' ignore='no'>
+			<description>Initial collection count</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response="no">
+				<method>PROPFIND</method>
+				<ruri>$calendarhome2:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/count.xml</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+				<grabcount>$calendarhome2count:</grabcount>
+			</request>
+		</test>
+		<test name='2' ignore='no'>
 			<description>POST invitation</description>
 			<request print-response='no'>
 				<method>POST</method>
@@ -66,7 +85,7 @@
 				</verify>
 			</request>
 		</test>
-		<test name='2'>
+		<test name='3'>
 			<description>Check Sharee notification collection</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
 				<method>WAITCOUNT 1</method>
@@ -84,7 +103,7 @@
 				</grabelement>
 			</request>
 		</test>
-		<test name='3'>
+		<test name='4'>
 			<description>Sharee replies ACCEPTED</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
 				<method>POST</method>
@@ -102,7 +121,7 @@
 				</grabelement>
 			</request>
 		</test>
-		<test name='4' ignore='no'>
+		<test name='5' ignore='no'>
 			<description>One more calendar</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response="no">
 				<method>PROPFIND</method>
@@ -116,28 +135,15 @@
 					<filepath>Resource/Common/PROPFIND/count.xml</filepath>
 				</data>
 				<verify>
-					<exclude-feature>
-						<feature>split-calendars</feature>
-					</exclude-feature>
 					<callback>multistatusItems</callback>
 					<arg>
 						<name>count</name>
-						<value>7</value>
+						<value>$calendarhome2count:+1</value>
 					</arg>
 				</verify>
-				<verify>
-					<require-feature>
-						<feature>split-calendars</feature>
-					</require-feature>
-					<callback>multistatusItems</callback>
-					<arg>
-						<name>count</name>
-						<value>8</value>
-					</arg>
-				</verify>
 			</request>
 		</test>
-		<test name='5' ignore='no'>
+		<test name='6' ignore='no'>
 			<description>One more calendar</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response="no">
 				<method>PROPFIND</method>
@@ -163,6 +169,25 @@
 	
 	<test-suite name='Send new invite #2'>
 		<test name='1' ignore='no'>
+			<description>Initial collection count</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response="no">
+				<method>PROPFIND</method>
+				<ruri>$calendarhome2:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/count.xml</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+				<grabcount>$calendarhome2count:</grabcount>
+			</request>
+		</test>
+		<test name='2' ignore='no'>
 			<description>POST invitation</description>
 			<request print-response='no'>
 				<method>POST</method>
@@ -176,7 +201,7 @@
 				</verify>
 			</request>
 		</test>
-		<test name='2'>
+		<test name='3'>
 			<description>Check Sharee notification collection</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
 				<method>WAITCOUNT 2</method>
@@ -194,7 +219,7 @@
 				</grabelement>
 			</request>
 		</test>
-		<test name='3'>
+		<test name='4'>
 			<description>Sharee replies ACCEPTED</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
 				<method>POST</method>
@@ -212,7 +237,7 @@
 				</grabelement>
 			</request>
 		</test>
-		<test name='4' ignore='no'>
+		<test name='5' ignore='no'>
 			<description>One more calendar</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response="no">
 				<method>PROPFIND</method>
@@ -226,28 +251,15 @@
 					<filepath>Resource/Common/PROPFIND/count.xml</filepath>
 				</data>
 				<verify>
-					<exclude-feature>
-						<feature>split-calendars</feature>
-					</exclude-feature>
 					<callback>multistatusItems</callback>
 					<arg>
 						<name>count</name>
-						<value>8</value>
+						<value>$calendarhome2count:+1</value>
 					</arg>
 				</verify>
-				<verify>
-					<require-feature>
-						<feature>split-calendars</feature>
-					</require-feature>
-					<callback>multistatusItems</callback>
-					<arg>
-						<name>count</name>
-						<value>9</value>
-					</arg>
-				</verify>
 			</request>
 		</test>
-		<test name='5' ignore='no'>
+		<test name='6' ignore='no'>
 			<description>One more calendar</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response="no">
 				<method>PROPFIND</method>
@@ -273,6 +285,25 @@
 	
 	<test-suite name='Uninvite #2'>
 		<test name='1' ignore='no'>
+			<description>Initial collection count</description>
+			<request user="$userid2:" pswd="$pswd2:" print-response="no">
+				<method>PROPFIND</method>
+				<ruri>$calendarhome2:/</ruri>
+				<header>
+					<name>Depth</name>
+					<value>1</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/Common/PROPFIND/count.xml</filepath>
+				</data>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+				<grabcount>$calendarhome2count:</grabcount>
+			</request>
+		</test>
+		<test name='2' ignore='no'>
 			<description>POST invitation</description>
 			<request print-response='no'>
 				<method>POST</method>
@@ -286,7 +317,7 @@
 				</verify>
 			</request>
 		</test>
-		<test name='2'>
+		<test name='3'>
 			<description>Check Sharee notification collection</description>
 			<request user="$userid2:" pswd="$pswd2:" print-response='no'>
 				<method>PROPFIND</method>
@@ -322,25 +353,12 @@
 					<filepath>Resource/Common/PROPFIND/count.xml</filepath>
 				</data>
 				<verify>
-					<exclude-feature>
-						<feature>split-calendars</feature>
-					</exclude-feature>
 					<callback>multistatusItems</callback>
 					<arg>
 						<name>count</name>
-						<value>7</value>
+						<value>$calendarhome2count:-1</value>
 					</arg>
 				</verify>
-				<verify>
-					<require-feature>
-						<feature>split-calendars</feature>
-					</require-feature>
-					<callback>multistatusItems</callback>
-					<arg>
-						<name>count</name>
-						<value>8</value>
-					</arg>
-				</verify>
 			</request>
 		</test>
 		<test name='5' ignore='no'>

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CardDAV/caldavtest.dtd
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CardDAV/caldavtest.dtd	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/scripts/tests/CardDAV/caldavtest.dtd	2012-11-28 18:38:02 UTC (rev 10099)
@@ -29,7 +29,8 @@
 
 	<!ELEMENT pause EMPTY>
 
-	<!ELEMENT request (require-feature?, exclude-feature?, method, ruri*, header*, data?, verify*, graburi?, grabheader*, grabproperty*, grabelement*)>
+	<!ELEMENT request (require-feature?, exclude-feature?, method, ruri*, header*, data?, verify*,
+						graburi?, grabcount?, grabheader*, grabproperty*, grabelement*, grabcalproperty*, grabcalparameter*)>
 		<!ATTLIST request auth (yes|no) "yes"
 						 user CDATA ""
 						 pswd CDATA ""
@@ -54,6 +55,8 @@
 		
 		<!ELEMENT graburi (#PCDATA)>
 
+		<!ELEMENT grabcount (#PCDATA)>
+
 		<!ELEMENT grabheader (name, variable)>
 	
 		<!ELEMENT grabproperty (property, variable)>
@@ -62,6 +65,9 @@
 
 		<!ELEMENT grabelement (name, variable+)>
 
+		<!ELEMENT grabcalproperty (name, variable)>
+		<!ELEMENT grabcalparameter (name, variable)>
+
 	<!ELEMENT test-suite (require-feature?, exclude-feature?, test*)>
 		<!ATTLIST test-suite name CDATA #REQUIRED
 							ignore (yes|no) "no"

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/src/caldavtest.py
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/src/caldavtest.py	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/src/caldavtest.py	2012-11-28 18:38:02 UTC (rev 10099)
@@ -581,6 +581,18 @@
         if req.graburi:
             self.manager.server_info.addextrasubs({req.graburi: self.grabbedlocation})
 
+        if req.grabcount:
+            ctr = None
+            if result and (response is not None) and (response.status == 207) and (respdata is not None):
+                tree = ElementTree(file=StringIO(respdata))
+                ctr = len(tree.findall("{DAV:}response")) - 1
+
+            if ctr == None or ctr == -1:
+                result = False
+                resulttxt += "\nCould not count resources in response\n"
+            else:
+                self.manager.server_info.addextrasubs({req.grabcount: str(ctr)})
+
         if req.grabheader:
             for hdrname, variable in req.grabheader:
                 hdrs = response.msg.getheaders(hdrname)

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/src/request.py
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/src/request.py	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/src/request.py	2012-11-28 18:38:02 UTC (rev 10099)
@@ -157,6 +157,7 @@
         self.count = 1
         self.verifiers = []
         self.graburi = None
+        self.grabcount = None
         self.grabheader = []
         self.grabproperty = []
         self.grabelement = []
@@ -346,6 +347,8 @@
                 self.verifiers[-1].parseXML(child)
             elif child.tag == src.xmlDefs.ELEMENT_GRABURI:
                 self.graburi = child.text.encode("utf-8")
+            elif child.tag == src.xmlDefs.ELEMENT_GRABCOUNT:
+                self.grabcount = child.text.encode("utf-8")
             elif child.tag == src.xmlDefs.ELEMENT_GRABHEADER:
                 self.parseGrab(child, self.grabheader)
             elif child.tag == src.xmlDefs.ELEMENT_GRABPROPERTY:

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/src/xmlDefs.py
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/src/xmlDefs.py	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/src/xmlDefs.py	2012-11-28 18:38:02 UTC (rev 10099)
@@ -32,6 +32,7 @@
 ELEMENT_FILEPATH = "filepath"
 ELEMENT_GRABCALPROP = "grabcalproperty"
 ELEMENT_GRABCALPARAM = "grabcalparameter"
+ELEMENT_GRABCOUNT = "grabcount"
 ELEMENT_GRABELEMENT = "grabelement"
 ELEMENT_GRABHEADER = "grabheader"
 ELEMENT_GRABPROPERTY = "grabproperty"

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/multistatusItems.py
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/multistatusItems.py	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/multistatusItems.py	2012-11-28 18:38:02 UTC (rev 10099)
@@ -52,9 +52,9 @@
         for k, v in args.items():
             v = [prefix + i for i in v]
             args[k] = v
-        count = [int(i) for i in count]
-        totalcount = [int(i) for i in totalcount]
-        responsecount = [int(i) for i in responsecount]
+        count = [int(eval(i)) for i in count]
+        totalcount = [int(eval(i)) for i in totalcount]
+        responsecount = [int(eval(i)) for i in responsecount]
 
         if "okhrefs" in args or "nohrefs" in args or "badhrefs" in args:
             doOKBad = True

Modified: CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/propfindItems.py
===================================================================
--- CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/propfindItems.py	2012-11-28 17:35:29 UTC (rev 10098)
+++ CalDAVTester/branches/users/cdaboo/managed-attachments/verifiers/propfindItems.py	2012-11-28 18:38:02 UTC (rev 10099)
@@ -33,7 +33,7 @@
         # Check how many responses are returned
         counts = args.get("count", [])
         if len(counts) == 1:
-            count = int(counts[0])
+            count = int(eval(counts[0]))
         else:
             count = None
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121128/ed7de71a/attachment-0001.html>


More information about the calendarserver-changes mailing list