<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15663] CalDAVTester/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15663">15663</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2016-06-09 14:06:10 -0700 (Thu, 09 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Display request/response if requested in the log observer. Provide a way to test for JSON null values.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunkREADMEtxt">CalDAVTester/trunk/README.txt</a></li>
<li><a href="#CalDAVTestertrunksrccaldavtestpy">CalDAVTester/trunk/src/caldavtest.py</a></li>
<li><a href="#CalDAVTestertrunksrcobserversbasepy">CalDAVTester/trunk/src/observers/base.py</a></li>
<li><a href="#CalDAVTestertrunksrcobserverslogpy">CalDAVTester/trunk/src/observers/log.py</a></li>
<li><a href="#CalDAVTestertrunkverifiersjsonPointerMatchpy">CalDAVTester/trunk/verifiers/jsonPointerMatch.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalDAVTestertrunkREADMEtxt"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/README.txt (15662 => 15663)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/README.txt        2016-06-09 20:52:09 UTC (rev 15662)
+++ CalDAVTester/trunk/README.txt        2016-06-09 21:06:10 UTC (rev 15663)
</span><span class="lines">@@ -617,9 +617,9 @@
</span><span class="cx">         is a match, otherwise False.
</span><span class="cx">         The pointer is the absolute pointer from the root down. A JSON object's
</span><span class="cx">         string value can be checked by append &quot;~$&quot; and the string value to test
</span><del>-        to the JSON pointer value. A single &quot;.&quot; can be used as a reference-token
-        in the JSON pointer to match against any member or array item at that
-        position in the document.
</del><ins>+        to the JSON pointer value. To test for a null value append &quot;~~&quot;. A single
+        &quot;.&quot; can be used as a reference-token in the JSON pointer to match against
+        any member or array item at that position in the document.
</ins><span class="cx">         
</span><span class="cx">         Argument: 'exists'
</span><span class="cx">                 JSON pointer for a JSON item to check the presence of
</span></span></pre></div>
<a id="CalDAVTestertrunksrccaldavtestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/caldavtest.py (15662 => 15663)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/caldavtest.py        2016-06-09 20:52:09 UTC (rev 15662)
+++ CalDAVTester/trunk/src/caldavtest.py        2016-06-09 21:06:10 UTC (rev 15663)
</span><span class="lines">@@ -769,15 +769,17 @@
</span><span class="cx">                 resulttxt += &quot;Status Code Error: %d&quot; % response.status
</span><span class="cx"> 
</span><span class="cx">         if req.print_request or (self.manager.print_request_response_on_error and not result):
</span><del>-            resulttxt += &quot;\n-------BEGIN:REQUEST-------\n&quot;
-            resulttxt += http.requestData
-            resulttxt += &quot;\n--------END:REQUEST--------\n&quot;
</del><ins>+            requesttxt = &quot;\n-------BEGIN:REQUEST-------\n&quot;
+            requesttxt += http.requestData
+            requesttxt += &quot;\n--------END:REQUEST--------\n&quot;
+            self.manager.message(&quot;protocol&quot;, requesttxt)
</ins><span class="cx"> 
</span><span class="cx">         if req.print_response or (self.manager.print_request_response_on_error and not result):
</span><del>-            resulttxt += &quot;\n-------BEGIN:RESPONSE-------\n&quot;
-            resulttxt += &quot;%s %s %s\n&quot; % (getVersionStringFromResponse(response), response.status, response.reason,)
-            resulttxt += str(response.msg) + &quot;\n&quot; + respdata
-            resulttxt += &quot;\n--------END:RESPONSE--------\n&quot;
</del><ins>+            responsetxt = &quot;\n-------BEGIN:RESPONSE-------\n&quot;
+            responsetxt += &quot;%s %s %s\n&quot; % (getVersionStringFromResponse(response), response.status, response.reason,)
+            responsetxt += str(response.msg) + &quot;\n&quot; + respdata
+            responsetxt += &quot;\n--------END:RESPONSE--------\n&quot;
+            self.manager.message(&quot;protocol&quot;, responsetxt)
</ins><span class="cx"> 
</span><span class="cx">         if etags is not None and req.method == &quot;GET&quot;:
</span><span class="cx">             hdrs = response.msg.getheaders(&quot;Etag&quot;)
</span></span></pre></div>
<a id="CalDAVTestertrunksrcobserversbasepy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/observers/base.py (15662 => 15663)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/observers/base.py        2016-06-09 20:52:09 UTC (rev 15662)
+++ CalDAVTester/trunk/src/observers/base.py        2016-06-09 21:06:10 UTC (rev 15663)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">     testFile - add a test file
</span><span class="cx">     testSuite - add a test suite
</span><span class="cx">     testResult - add a test result
</span><ins>+    protocol - protocol log
</ins><span class="cx">     finish - tests completed
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalDAVTestertrunksrcobserverslogpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/observers/log.py (15662 => 15663)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/observers/log.py        2016-06-09 20:52:09 UTC (rev 15662)
+++ CalDAVTester/trunk/src/observers/log.py        2016-06-09 21:06:10 UTC (rev 15663)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx">         self.loggedFailures = []
</span><span class="cx">         self.currentFile = None
</span><span class="cx">         self.currentSuite = None
</span><ins>+        self.currentProtocol = []
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def updateCalls(self):
</span><span class="lines">@@ -46,6 +47,7 @@
</span><span class="cx">             &quot;testFile&quot;: self.testFile,
</span><span class="cx">             &quot;testSuite&quot;: self.testSuite,
</span><span class="cx">             &quot;testResult&quot;: self.testResult,
</span><ins>+            &quot;protocol&quot;: self.protocol,
</ins><span class="cx">             &quot;finish&quot;: self.finish,
</span><span class="cx">         })
</span><span class="cx"> 
</span><span class="lines">@@ -101,7 +103,11 @@
</span><span class="cx">             )
</span><span class="cx">             self.loggedFailures.append(failtxt)
</span><span class="cx"> 
</span><ins>+        if self.currentProtocol:
+            self.manager.logit(&quot;\n&quot;.join(self.currentProtocol))
+            self.currentProtocol = []
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     def _logResult(self, name, result):
</span><span class="cx">         if result[&quot;result&quot;] is not None:
</span><span class="cx">             result_value = self.RESULT_STRINGS[result[&quot;result&quot;]]
</span><span class="lines">@@ -112,6 +118,10 @@
</span><span class="cx">             self.manager.logit(result[&quot;details&quot;])
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def protocol(self, result):
+        self.currentProtocol.append(result)
+
+
</ins><span class="cx">     def finish(self):
</span><span class="cx">         self.manager.logit(&quot;&quot;)
</span><span class="cx">         if self.manager.totals[manager.RESULT_FAILED] + self.manager.totals[manager.RESULT_ERROR] != 0:
</span></span></pre></div>
<a id="CalDAVTestertrunkverifiersjsonPointerMatchpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/verifiers/jsonPointerMatch.py (15662 => 15663)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/verifiers/jsonPointerMatch.py        2016-06-09 20:52:09 UTC (rev 15662)
+++ CalDAVTester/trunk/verifiers/jsonPointerMatch.py        2016-06-09 21:06:10 UTC (rev 15663)
</span><span class="lines">@@ -29,6 +29,13 @@
</span><span class="cx"> 
</span><span class="cx"> class Verifier(object):
</span><span class="cx"> 
</span><ins>+    class JsonNull(object):
+        pass
+
+
+    null = JsonNull()
+
+
</ins><span class="cx">     def verify(self, manager, uri, response, respdata, args): #@UnusedVariable
</span><span class="cx">         # Get arguments
</span><span class="cx">         statusCodes = args.get(&quot;status&quot;, [&quot;200&quot;, ])
</span><span class="lines">@@ -65,6 +72,8 @@
</span><span class="cx">         for jpath in exists:
</span><span class="cx">             if jpath.find(&quot;~$&quot;) != -1:
</span><span class="cx">                 path, value = jpath.split(&quot;~$&quot;)
</span><ins>+            elif jpath.find(&quot;~~&quot;) != -1:
+                path, value = jpath.split(&quot;~~&quot;)[0], self.null
</ins><span class="cx">             else:
</span><span class="cx">                 path, value = jpath, None
</span><span class="cx">             try:
</span><span class="lines">@@ -78,7 +87,7 @@
</span><span class="cx">                     if not jobjs:
</span><span class="cx">                         result = False
</span><span class="cx">                         resulttxt += &quot;        Items not returned in JSON for %s\n&quot; % (path,)
</span><del>-                    if value and value not in map(str, jobjs):
</del><ins>+                    if value and value not in map(lambda x: self.null if x is None else str(x), jobjs):
</ins><span class="cx">                         result = False
</span><span class="cx">                         resulttxt += &quot;        Item values not returned in JSON for %s\n&quot; % (jpath,)
</span><span class="cx">                 except JSONPointerMatchError:
</span></span></pre>
</div>
</div>

</body>
</html>