[CalendarServer-changes] [7250] CalendarServer/branches/users/glyph/subtransactions/twext/enterprise

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 24 13:35:44 PDT 2011


Revision: 7250
          http://trac.macosforge.org/projects/calendarserver/changeset/7250
Author:   glyph at apple.com
Date:     2011-03-24 13:35:44 -0700 (Thu, 24 Mar 2011)
Log Message:
-----------
address small test coverage issue so it's easier to see uncovered lines in commandBlock implementation

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/adbapi2.py
    CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/test/test_adbapi2.py

Modified: CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/adbapi2.py	2011-03-24 20:35:13 UTC (rev 7249)
+++ CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/adbapi2.py	2011-03-24 20:35:44 UTC (rev 7250)
@@ -330,6 +330,10 @@
 
 
     def abort(self):
+        """
+        Succeed and do nothing.  The actual logic for this method is mostly
+        implemented by L{_SingleTxn._stopWaiting}.
+        """
         return succeed(None)
 
 
@@ -436,10 +440,10 @@
 
     def abort(self):
         self._markComplete()
+        result = super(_SingleTxn, self).abort()
         if self in self._pool._waiting:
             self._stopWaiting()
-            return succeed(None)
-        return super(_SingleTxn, self).abort()
+        return result
 
 
     def _stopWaiting(self):

Modified: CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/test/test_adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/test/test_adbapi2.py	2011-03-24 20:35:13 UTC (rev 7249)
+++ CalendarServer/branches/users/glyph/subtransactions/twext/enterprise/test/test_adbapi2.py	2011-03-24 20:35:44 UTC (rev 7250)
@@ -655,6 +655,24 @@
         self.assertEquals(resultOf(self.pool.stopService()), [None])
 
 
+    def test_abortSpooled(self):
+        """
+        Aborting a still-spooled transaction (one which has no statements being
+        executed) will result in all of its Deferreds immediately failing and
+        none of the queued statements being executed.
+        """
+        # Use up the available connections ...
+        for i in xrange(self.pool.maxConnections):
+            self.pool.connection()
+        # ... so that this one has to be spooled.
+        spooled = self.pool.connection()
+        result = resultOf(spooled.execSQL("alpha"))
+        # sanity check, it would be bad if this actually executed.
+        self.assertEqual(result, [])
+        spooled.abort()
+        self.assertEqual(result[0].type, ConnectionError)
+
+
     def test_waitForAlreadyAbortedTransaction(self):
         """
         L{ConnectionPool.stopService} will wait for all transactions to shut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110324/6f9f57f4/attachment.html>


More information about the calendarserver-changes mailing list