<!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>[12109] twext/trunk/twext/enterprise/test/test_queue.py</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/12109">12109</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2013-12-13 20:45:59 -0800 (Fri, 13 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Oh the insanity</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#twexttrunktwextenterprisetesttest_queuepy">twext/trunk/twext/enterprise/test/test_queue.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="twexttrunktwextenterprisetesttest_queuepy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/enterprise/test/test_queue.py (12108 => 12109)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/enterprise/test/test_queue.py        2013-12-14 04:34:13 UTC (rev 12108)
+++ twext/trunk/twext/enterprise/test/test_queue.py        2013-12-14 04:45:59 UTC (rev 12109)
</span><span class="lines">@@ -20,48 +20,40 @@
</span><span class="cx"> 
</span><span class="cx"> import datetime
</span><span class="cx"> 
</span><del>-# TODO: There should be a store-building utility within twext.enterprise.
</del><ins>+from zope.interface.verify import verifyObject
</ins><span class="cx"> 
</span><del>-from twisted.protocols.amp import Command
-from twisted.internet.task import Clock as _Clock
-
-from txdav.common.datastore.test.util import buildStore
-
-from twext.enterprise.dal.syntax import SchemaSyntax, Select
-from twext.enterprise.dal.record import fromTable
-from twext.enterprise.dal.test.test_parseschema import SchemaTestHelper
-
-from twext.enterprise.queue import (
-    inTransaction, PeerConnectionPool, WorkItem, astimestamp
-)
-
-from twisted.trial.unittest import TestCase
</del><span class="cx"> from twisted.python.failure import Failure
</span><ins>+from twisted.trial.unittest import TestCase, SkipTest
+from twisted.test.proto_helpers import StringTransport, MemoryReactor
</ins><span class="cx"> from twisted.internet.defer import (
</span><del>-    Deferred, inlineCallbacks, gatherResults, passthru
</del><ins>+    Deferred, inlineCallbacks, gatherResults, passthru, returnValue
</ins><span class="cx"> )
</span><del>-
</del><ins>+from twisted.internet.task import Clock as _Clock
+from twisted.protocols.amp import Command
</ins><span class="cx"> from twisted.application.service import Service, MultiService
</span><span class="cx"> 
</span><ins>+from twext.enterprise.dal.syntax import SchemaSyntax, Select
+from twext.enterprise.dal.record import fromTable, Record
+from twext.enterprise.dal.test.test_parseschema import SchemaTestHelper
+from twext.enterprise.fixtures import buildConnectionPool
+from twext.enterprise.fixtures import SteppablePoolHelper
+from twext.enterprise.fixtures import ConnectionPoolHelper
</ins><span class="cx"> from twext.enterprise.queue import (
</span><ins>+    inTransaction, PeerConnectionPool, WorkItem, astimestamp,
</ins><span class="cx">     LocalPerformer, _IWorkPerformer, WorkerConnectionPool, SchemaAMP,
</span><del>-    TableSyntaxByName
</del><ins>+    TableSyntaxByName, ConnectionFromPeerNode, LocalQueuer,
+    _BaseQueuer, NonPerformingQueuer
</ins><span class="cx"> )
</span><del>-
-from twext.enterprise.dal.record import Record
-
-from twext.enterprise.queue import ConnectionFromPeerNode
-from twext.enterprise.fixtures import buildConnectionPool
-from zope.interface.verify import verifyObject
-from twisted.test.proto_helpers import StringTransport, MemoryReactor
-from twext.enterprise.fixtures import SteppablePoolHelper
-from twisted.internet.defer import returnValue
-from twext.enterprise.queue import LocalQueuer
-from twext.enterprise.fixtures import ConnectionPoolHelper
-
-from twext.enterprise.queue import _BaseQueuer, NonPerformingQueuer
</del><span class="cx"> import twext.enterprise.queue
</span><span class="cx"> 
</span><ins>+# TODO: There should be a store-building utility within twext.enterprise.
+try:
+    from txdav.common.datastore.test.util import buildStore
+except ImportError:
+    def buildStore(*args, **kwargs):
+        raise SkipTest(
+            &quot;buildStore is not available, because it's in txdav; duh.&quot;
+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class Clock(_Clock):
</span><span class="lines">@@ -191,30 +183,40 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> )
</span><span class="cx"> 
</span><del>-schema = SchemaSyntax(SimpleSchemaHelper().schemaFromString(schemaText))
</del><ins>+try:
+    schema = SchemaSyntax(SimpleSchemaHelper().schemaFromString(schemaText))
</ins><span class="cx"> 
</span><del>-dropSQL = [
-    &quot;drop table {name}&quot;.format(name=table.model.name)
-    for table in schema
-]
</del><ins>+    dropSQL = [
+        &quot;drop table {name}&quot;.format(name=table.model.name)
+        for table in schema
+    ]
+except SkipTest as e:
+    DummyWorkDone = DummyWorkItem = object
+    skip = e
+else:
+    DummyWorkDone = fromTable(schema.DUMMY_WORK_DONE)
+    DummyWorkItem = fromTable(schema.DUMMY_WORK_ITEM)
+    skip = False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-class DummyWorkDone(Record, fromTable(schema.DUMMY_WORK_DONE)):
</del><ins>+
+class DummyWorkDone(Record, DummyWorkDone):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Work result.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-class DummyWorkItem(WorkItem, fromTable(schema.DUMMY_WORK_ITEM)):
</del><ins>+class DummyWorkItem(WorkItem, DummyWorkItem):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Sample L{WorkItem} subclass that adds two integers together and stores them
</span><span class="cx">     in another table.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     def doWork(self):
</span><del>-        return DummyWorkDone.create(self.transaction, workID=self.workID,
-                                    aPlusB=self.a + self.b)
</del><ins>+        return DummyWorkDone.create(
+            self.transaction, workID=self.workID, aPlusB=self.a + self.b
+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @classmethod
</span><span class="lines">@@ -277,8 +279,9 @@
</span><span class="cx">         L{WorkItem.forTable} returns L{WorkItem} subclasses mapped to the given
</span><span class="cx">         table.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        self.assertIdentical(WorkItem.forTable(schema.DUMMY_WORK_ITEM),
-                             DummyWorkItem)
</del><ins>+        self.assertIdentical(
+            WorkItem.forTable(schema.DUMMY_WORK_ITEM), DummyWorkItem
+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>