<!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>[13618] 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/13618">13618</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-06-09 09:03:29 -0700 (Mon, 09 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add the ability to have a set of tests always run before and/or after every regular test (useful for verifying tests have cleaned up after themselves).</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunksrcmanagerpy">CalDAVTester/trunk/src/manager.py</a></li>
<li><a href="#CalDAVTestertrunksrcrequestpy">CalDAVTester/trunk/src/request.py</a></li>
<li><a href="#CalDAVTestertrunkverifiersmultistatusItemspy">CalDAVTester/trunk/verifiers/multistatusItems.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunkscriptstestsCalDAVpretestxml">CalDAVTester/trunk/scripts/tests/CalDAV/pretest.xml</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalDAVTestertrunkscriptstestsCalDAVpretestxml"></a>
<div class="addfile"><h4>Added: CalDAVTester/trunk/scripts/tests/CalDAV/pretest.xml (0 => 13618)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/scripts/tests/CalDAV/pretest.xml         (rev 0)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/pretest.xml        2014-06-09 16:03:29 UTC (rev 13618)
</span><span class="lines">@@ -0,0 +1,165 @@
</span><ins>+<?xml version="1.0" standalone="no"?>
+
+<!DOCTYPE caldavtest SYSTEM "caldavtest.dtd">
+
+<!--
+ Copyright (c) 2006-2013 Apple Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<caldavtest ignore-all="yes">
+        <require-feature>
+                <feature>caldav</feature>
+        </require-feature>
+
+        <start/>
+        
+        <test-suite name='User calendars and inboxes are empty'>
+                <test name='1'>
+                        <description>PROPFIND of basic properties depth=0</description>
+                        <request>
+                                <method>PROPFIND</method>
+                                <ruri>$calendarpath1:/</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>multistatusItems</callback>
+                                        <arg>
+                                                <name>count</name>
+                                                <value>0</value>
+                                        </arg>
+                                </verify>
+                        </request>
+                </test>
+                <test name='1'>
+                        <description>PROPFIND of basic properties depth=0</description>
+                        <request>
+                                <method>PROPFIND</method>
+                                <ruri>$inboxpath1:/</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>multistatusItems</callback>
+                                        <arg>
+                                                <name>count</name>
+                                                <value>0</value>
+                                        </arg>
+                                </verify>
+                        </request>
+                </test>
+                <test name='3'>
+                        <description>PROPFIND of basic properties depth=0</description>
+                        <request user="$userid2:" pswd="$pswd2:">
+                                <method>PROPFIND</method>
+                                <ruri>$calendarpath2:/</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>multistatusItems</callback>
+                                        <arg>
+                                                <name>count</name>
+                                                <value>0</value>
+                                        </arg>
+                                </verify>
+                        </request>
+                </test>
+                <test name='4'>
+                        <description>PROPFIND of basic properties depth=0</description>
+                        <request user="$userid2:" pswd="$pswd2:">
+                                <method>PROPFIND</method>
+                                <ruri>$inboxpath2:/</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>multistatusItems</callback>
+                                        <arg>
+                                                <name>count</name>
+                                                <value>0</value>
+                                        </arg>
+                                </verify>
+                        </request>
+                </test>
+                <test name='5'>
+                        <description>PROPFIND of basic properties depth=0</description>
+                        <request user="$userid3:" pswd="$pswd3:">
+                                <method>PROPFIND</method>
+                                <ruri>$calendarpath3:/</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>multistatusItems</callback>
+                                        <arg>
+                                                <name>count</name>
+                                                <value>0</value>
+                                        </arg>
+                                </verify>
+                        </request>
+                </test>
+                <test name='6'>
+                        <description>PROPFIND of basic properties depth=0</description>
+                        <request user="$userid3:" pswd="$pswd3:">
+                                <method>PROPFIND</method>
+                                <ruri>$inboxpath3:/</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>multistatusItems</callback>
+                                        <arg>
+                                                <name>count</name>
+                                                <value>0</value>
+                                        </arg>
+                                </verify>
+                        </request>
+                </test>
+        </test-suite>
+
+        <end/>
+        
+</caldavtest>
</ins></span></pre></div>
<a id="CalDAVTestertrunksrcmanagerpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/manager.py (13617 => 13618)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/manager.py        2014-06-09 15:07:45 UTC (rev 13617)
+++ CalDAVTester/trunk/src/manager.py        2014-06-09 16:03:29 UTC (rev 13618)
</span><span class="lines">@@ -48,6 +48,8 @@
</span><span class="cx">
</span><span class="cx"> def __init__(self, text=True):
</span><span class="cx"> self.server_info = serverinfo()
</span><ins>+ self.pretest = None
+ self.posttest = None
</ins><span class="cx"> self.tests = []
</span><span class="cx"> self.textMode = text
</span><span class="cx"> self.pid = 0
</span><span class="lines">@@ -162,33 +164,45 @@
</span><span class="cx">
</span><span class="cx"> self.server_info.addsubs(moresubs)
</span><span class="cx">
</span><del>- for ctr, testfile in enumerate(testfiles):
- self.message("load", testfile, ctr + 1, len(testfiles))
-
</del><ins>+ from src.caldavtest import caldavtest
+ def _loadFile(fname, ignore_root=True):
</ins><span class="cx"> # Open and parse the config file
</span><span class="cx"> try:
</span><del>- tree = ElementTree(file=testfile)
</del><ins>+ tree = ElementTree(file=fname)
</ins><span class="cx"> except ExpatError, e:
</span><del>- raise RuntimeError("Unable to parse file '%s' because: %s" % (testfile, e,))
-
- # Verify that top-level element is correct
- from src.caldavtest import caldavtest
</del><ins>+ raise RuntimeError("Unable to parse file '%s' because: %s" % (fname, e,))
</ins><span class="cx"> caldavtest_node = tree.getroot()
</span><span class="cx"> if caldavtest_node.tag != src.xmlDefs.ELEMENT_CALDAVTEST:
</span><del>- self.message("trace", "Ignoring file \"{}\" because it is not a test file".format(testfile))
- continue
</del><ins>+ if ignore_root:
+ self.message("trace", "Ignoring file \"{}\" because it is not a test file".format(fname))
+ return None
+ else:
+ raise EX_INVALID_CONFIG_FILE
</ins><span class="cx"> if not len(caldavtest_node):
</span><span class="cx"> raise EX_INVALID_CONFIG_FILE
</span><del>- self.message("Reading Test Details from \"{}\"".format(testfile))
</del><span class="cx">
</span><del>- # parse all the config data
- test = caldavtest(self, testfile)
</del><ins>+ self.message("Reading Test Details from \"{}\"".format(fname))
+ test = caldavtest(self, fname)
</ins><span class="cx"> test.parseXML(caldavtest_node)
</span><ins>+ return test
</ins><span class="cx">
</span><ins>+ for ctr, testfile in enumerate(testfiles):
+ self.message("load", testfile, ctr + 1, len(testfiles))
+
+ # Open and parse the config file
+ test = _loadFile(testfile)
+ if test is None:
+ continue
+
</ins><span class="cx"> # ignore if all mode and ignore-all is set
</span><span class="cx"> if not all or not test.ignore_all:
</span><span class="cx"> self.tests.append(test)
</span><span class="cx">
</span><ins>+ if self.pretest is not None:
+ self.pretest = _loadFile(self.pretest, False)
+ if self.posttest is not None:
+ self.posttest = _loadFile(self.posttest, False)
+
</ins><span class="cx"> self.message("load", None, ctr + 1, len(testfiles))
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -213,6 +227,8 @@
</span><span class="cx"> "all",
</span><span class="cx"> "subdir=",
</span><span class="cx"> "exclude=",
</span><ins>+ "pretest=",
+ "posttest=",
</ins><span class="cx"> "observer=",
</span><span class="cx"> "pid=",
</span><span class="cx"> "postgres-log=",
</span><span class="lines">@@ -239,6 +255,10 @@
</span><span class="cx"> subdir = value + "/"
</span><span class="cx"> elif option == "--exclude":
</span><span class="cx"> excludes.add(value)
</span><ins>+ elif option == "--pretest":
+ self.pretest = value
+ elif option == "--posttest":
+ self.posttest = value
</ins><span class="cx"> elif option == "-m":
</span><span class="cx"> self.memUsage = True
</span><span class="cx"> elif option == "-o":
</span><span class="lines">@@ -273,8 +293,7 @@
</span><span class="cx"> # Remove any server info file from files enumerated by --all
</span><span class="cx"> fnames[:] = [x for x in fnames if (x != sname)]
</span><span class="cx">
</span><del>- # Process any file arguments as test configs
- for f in args:
</del><ins>+ def _normPath(f):
</ins><span class="cx"> # paths starting with . or .. or /
</span><span class="cx"> if f[0] in ('.', '/'):
</span><span class="cx"> f = os.path.abspath(f)
</span><span class="lines">@@ -287,8 +306,17 @@
</span><span class="cx"> # relative paths
</span><span class="cx"> else:
</span><span class="cx"> f = os.path.join(dname, f)
</span><del>- fnames.append(f)
</del><ins>+ return f
</ins><span class="cx">
</span><ins>+ # Process any file arguments as test configs
+ for f in args:
+ fnames.append(_normPath(f))
+
+ if self.pretest is not None:
+ self.pretest = _normPath(self.pretest)
+ if self.posttest is not None:
+ self.posttest = _normPath(self.posttest)
+
</ins><span class="cx"> # Randomize file list
</span><span class="cx"> if random_order and len(fnames) > 1:
</span><span class="cx"> random.seed(random_seed)
</span><span class="lines">@@ -317,6 +345,16 @@
</span><span class="cx"> ignored = 0
</span><span class="cx"> try:
</span><span class="cx"> for test in self.tests:
</span><ins>+ if self.pretest is not None:
+ o, f, i = self.pretest.run()
+ ok += o
+ failed += f
+ ignored += i
+
+ # Always stop the tests if the pretest fails
+ if failed != 0:
+ break
+
</ins><span class="cx"> o, f, i = test.run()
</span><span class="cx"> ok += o
</span><span class="cx"> failed += f
</span><span class="lines">@@ -324,6 +362,17 @@
</span><span class="cx">
</span><span class="cx"> if failed != 0 and self.stoponfail:
</span><span class="cx"> break
</span><ins>+
+ if self.posttest is not None:
+ o, f, i = self.posttest.run()
+ ok += o
+ failed += f
+ ignored += i
+
+ # Always stop the tests if the posttest fails
+ if failed != 0:
+ break
+
</ins><span class="cx"> except:
</span><span class="cx"> failed += 1
</span><span class="cx"> import traceback
</span></span></pre></div>
<a id="CalDAVTestertrunksrcrequestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/request.py (13617 => 13618)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/request.py        2014-06-09 15:07:45 UTC (rev 13617)
+++ CalDAVTester/trunk/src/request.py        2014-06-09 16:03:29 UTC (rev 13618)
</span><span class="lines">@@ -519,9 +519,13 @@
</span><span class="cx">
</span><span class="cx"> verifierClass = self._importName("verifiers." + self.callback, "Verifier")
</span><span class="cx"> verifier = verifierClass()
</span><del>- return verifier.verify(self.manager, uri, response, respdata, self.args)
</del><span class="cx">
</span><ins>+ # Always clone the args as this verifier may be called multiple times
+ args = dict((k, list(v)) for k, v in self.args.items())
</ins><span class="cx">
</span><ins>+ return verifier.verify(self.manager, uri, response, respdata, args)
+
+
</ins><span class="cx"> def _importName(self, modulename, name):
</span><span class="cx"> """
</span><span class="cx"> Import a named object from a module in the context of this function.
</span></span></pre></div>
<a id="CalDAVTestertrunkverifiersmultistatusItemspy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/verifiers/multistatusItems.py (13617 => 13618)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/verifiers/multistatusItems.py        2014-06-09 15:07:45 UTC (rev 13617)
+++ CalDAVTester/trunk/verifiers/multistatusItems.py        2014-06-09 16:03:29 UTC (rev 13618)
</span><span class="lines">@@ -50,9 +50,6 @@
</span><span class="cx"> okhrefs = [(prefix + i).rstrip("/") for i in okhrefs]
</span><span class="cx"> nohrefs = [(prefix + i).rstrip("/") for i in nohrefs]
</span><span class="cx"> badhrefs = [(prefix + i).rstrip("/") for i in badhrefs]
</span><del>- for k, v in args.items():
- v = [prefix + i for i in v]
- args[k] = v
</del><span class="cx"> count = [int(eval(i)) for i in count]
</span><span class="cx"> totalcount = [int(eval(i)) for i in totalcount]
</span><span class="cx"> responsecount = [int(eval(i)) for i in responsecount]
</span></span></pre>
</div>
</div>
</body>
</html>