[CalendarServer-changes] [15443] CalDAVTester/trunk

source_changes at macosforge.org source_changes at macosforge.org
Sat Jan 23 10:33:22 PST 2016


Revision: 15443
          http://trac.calendarserver.org//changeset/15443
Author:   cdaboo at apple.com
Date:     2016-01-23 10:33:22 -0800 (Sat, 23 Jan 2016)
Log Message:
-----------
Tweaks to better support running tests for another type of server.

Modified Paths:
--------------
    CalDAVTester/trunk/README.txt
    CalDAVTester/trunk/src/manager.py
    CalDAVTester/trunk/src/serverinfo.py
    CalDAVTester/trunk/verifiers/dataString.py

Modified: CalDAVTester/trunk/README.txt
===================================================================
--- CalDAVTester/trunk/README.txt	2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/README.txt	2016-01-23 18:33:22 UTC (rev 15443)
@@ -398,11 +398,18 @@
 				ELEMENT <value>
 					values for the argument.
 	
-		ELEMENT <graburi>
-			if present, this stores the value of the actual request URI
-			used in a named variable which can be used in subsequent requests.
-			Useful for capturing URIs when the GETNEW method is used.
-			
+        ELEMENT <graburi>
+            if present, this stores the value of the actual request URI
+            used in a named variable which can be used in subsequent requests.
+            Useful for capturing URIs when the GETNEW method is used.
+            
+        ELEMENT <grabcount>
+            if present, this stores the number of child responses in a
+            {DAV:}multistatus response into the named variable which
+            can be used in subsequent requests. This is useful for
+            capturing the current count so that a change in the count
+            can be tested for later.
+            
 		ELEMENT <grabheader>
 			if present, this stores the value of the specified header
 			returned in the response in a named variable which can be used
@@ -413,11 +420,16 @@
 			returned in a PROPFIND response in a named variable which can
 			be used in subsequent requests.
 			
-		ELEMENT <grabelement>
-			if present, this stores the text representation of an XML
-			element extracted from the response body in a named variable
-			which can be used in subsequent requests.
-			
+        ELEMENT <grabelement>
+            if present, this stores the text representation of an XML
+            element extracted from the response body in a named variable
+            which can be used in subsequent requests.
+            
+        ELEMENT <grabjson>
+            if present, this stores the text representation of a JSON
+            object extracted from the response body in a named variable
+            which can be used in subsequent requests.
+            
 		ELEMENT <grabcalproperty>
 			if present, this stores a calendar property value in a named
 			variable which can be used in subsequent request. The syntax for
@@ -498,9 +510,12 @@
 	Performs a check of response body tries to find occurrences of the specified strings or the
 	absence of specified strings.
 
-	Argument: 'contains'
-		One or more strings that must be contained in the data (case-sensitive).
-	
+    Argument: 'equals'
+        One or more strings that must match exactly in the data (case-sensitive).
+    
+    Argument: 'contains'
+        One or more strings that must be contained in the data (case-sensitive).
+    
 	Argument: 'notcontains'
 		One or more strings that must not be contained in the data (case-sensitive).
 	
@@ -598,7 +613,7 @@
 	string value can be checked by append "~$" and the string value to test
 	to the JSON pointer value. A single "." can be used as a reference-token
 	in the JSON pointer to match against any member or array item at that
-	poisition in the document.
+	position in the document.
 	
 	Argument: 'exists'
 		JSON pointer for a JSON item to check the presence of
@@ -711,8 +726,8 @@
 	whether the returned properties (and optionally their values) are good (2xx) or bad
 	(non-2xx) response code. The overall response status must be 207.
 
-	Argument: 'roor-element'
-		Exepected root element for the XML response. Normally this is DAV:multistatus
+	Argument: 'root-element'
+		Expected root element for the XML response. Normally this is DAV:multistatus
 		but, e.g., MKCOL ext uses a different root, but mostly looks like multistatus
 		otherwise.
 
@@ -819,7 +834,7 @@
 		Any specified XML elements will have their content removed from the
 		response XML data before the comparison with the file data is done.
 		This can be used to ignore element values that change in each request,
-		e.g., a timestamp.
+		e.g., a time stamp.
 	
 	Example:
 	

Modified: CalDAVTester/trunk/src/manager.py
===================================================================
--- CalDAVTester/trunk/src/manager.py	2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/src/manager.py	2016-01-23 18:33:22 UTC (rev 15443)
@@ -47,6 +47,7 @@
 
     def __init__(self, text=True):
         self.server_info = serverinfo()
+        self.base_dir = ""
         self.data_dir = None
         self.pretest = None
         self.posttest = None
@@ -199,6 +200,8 @@
                 raise EX_INVALID_CONFIG_FILE
 
             self.message("Reading Test Details from \"{f}\"".format(f=fname))
+            if self.base_dir:
+                fname = fname[len(self.base_dir) + 1:]
             test = caldavtest(self, fname)
             test.parseXML(caldavtest_node)
             return test
@@ -226,7 +229,6 @@
     def readCommandLine(self):
         sname = "scripts/server/serverinfo.xml"
         dname = "scripts/tests"
-        basedir = None
         fnames = []
         ssl = False
         all = False
@@ -272,13 +274,13 @@
             elif option == "--all":
                 all = True
             elif option == "--basedir":
-                basedir = value
-                sname = os.path.join(basedir, "serverinfo.xml")
-                dname = os.path.join(basedir, "tests")
-                self.data_dir = os.path.join(basedir, "data")
+                self.base_dir = value
+                sname = os.path.join(self.base_dir, "serverinfo.xml")
+                dname = os.path.join(self.base_dir, "tests")
+                self.data_dir = os.path.join(self.base_dir, "data")
 
                 # Also add parent to PYTHON path
-                sys.path.append(os.path.dirname(basedir))
+                sys.path.append(os.path.dirname(self.base_dir))
 
             elif option == "--subdir":
                 subdir = value + "/"

Modified: CalDAVTester/trunk/src/serverinfo.py
===================================================================
--- CalDAVTester/trunk/src/serverinfo.py	2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/src/serverinfo.py	2016-01-23 18:33:22 UTC (rev 15443)
@@ -13,7 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-from uuid import uuid4
 
 """
 Class that encapsulates the server information for a CalDAV test run.
@@ -22,6 +21,8 @@
 import datetime
 import re
 import src.xmlDefs
+from uuid import uuid4
+from urlparse import urlparse
 
 
 class serverinfo(object):
@@ -147,6 +148,12 @@
             if variable.startswith("basename("):
                 variable = variable[len("basename("):-1]
                 value = value.rstrip("/").split("/")[-1]
+
+            # urlpath() - extract just the URL path segment from the value
+            elif variable.startswith("urlpath("):
+                variable = variable[len("urlpath("):-1]
+                value = urlparse(value).path
+
             processed[variable] = value
 
         self.addsubs(processed, self.extrasubsdict)

Modified: CalDAVTester/trunk/verifiers/dataString.py
===================================================================
--- CalDAVTester/trunk/verifiers/dataString.py	2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/verifiers/dataString.py	2016-01-23 18:33:22 UTC (rev 15443)
@@ -22,6 +22,7 @@
 
     def verify(self, manager, uri, response, respdata, args): #@UnusedVariable
         # Get arguments
+        equals = args.get("equals", [])
         contains = args.get("contains", [])
         notcontains = args.get("notcontains", [])
         unwrap = args.get("unwrap")
@@ -44,6 +45,10 @@
         else:
             newrespdata = respdata
         # Check each contains and not-contains (AND operation)
+        for item in equals:
+            item = manager.server_info.subs(item)
+            if newrespdata != item:
+                return False, "        Response data does not equal \"%s\"" % (item,)
         for item in contains:
             item = manager.server_info.subs(item)
             if newrespdata.find(item.replace("\n", "\r\n")) == -1 and newrespdata.find(item) == -1:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160123/d6f1d68e/attachment.html>


More information about the calendarserver-changes mailing list