[CalendarServer-changes] [10066] CalendarServer/branches/users/glyph/one-home-list-api

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 16 14:49:07 PST 2012


Revision: 10066
          http://trac.calendarserver.org//changeset/10066
Author:   glyph at apple.com
Date:     2012-11-16 14:49:07 -0800 (Fri, 16 Nov 2012)
Log Message:
-----------
Don't change the semantics of the whole test suite; allow this test to select its transaction-cleaning behavior.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/one-home-list-api/txdav/caldav/datastore/test/common.py
    CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/test/util.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/one-home-list-api/

Modified: CalendarServer/branches/users/glyph/one-home-list-api/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/one-home-list-api/txdav/caldav/datastore/test/common.py	2012-11-16 22:49:05 UTC (rev 10065)
+++ CalendarServer/branches/users/glyph/one-home-list-api/txdav/caldav/datastore/test/common.py	2012-11-16 22:49:07 UTC (rev 10066)
@@ -49,12 +49,12 @@
     ICalendarObject, ICalendarHome,
     ICalendar, IAttachment, ICalendarTransaction)
 
-
 from twistedcaldav.customxml import InviteNotification, InviteSummary
 from txdav.caldav.icalendarstore import IAttachmentStorageTransport
 from txdav.caldav.icalendarstore import QuotaExceeded
-from txdav.common.datastore.test.util import deriveQuota
-from txdav.common.datastore.test.util import withSpecialQuota
+from txdav.common.datastore.test.util import (
+    deriveQuota, withSpecialQuota, transactionClean
+)
 from txdav.common.icommondatastore import ConcurrentModification
 from twistedcaldav.ical import Component
 from twistedcaldav.config import config
@@ -2326,6 +2326,7 @@
             )
 
 
+    @transactionClean
     @inlineCallbacks
     def test_withEachCalendarHomeDont(self):
         """

Modified: CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/test/util.py	2012-11-16 22:49:05 UTC (rev 10065)
+++ CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/test/util.py	2012-11-16 22:49:07 UTC (rev 10066)
@@ -201,7 +201,8 @@
                 if wasBusy:
                     testCase.fail("Outstanding Transactions: " + busyText)
                 return ignored
-            stop.addBoth(checkWasBusy)
+            if deriveValue(testCase, _SPECIAL_TXN_CLEAN, lambda tc: False):
+                stop.addBoth(checkWasBusy)
             return stop
         testCase.addCleanup(stopIt)
         yield self.cleanStore(testCase, store)
@@ -260,13 +261,20 @@
     for that test.
 
     @param testCase: the test case instance.
+    @type testCase: L{TestCase}
 
     @param attribute: the name of the attribute (the same name passed to
         L{withSpecialValue}).
+    @type attribute: L{str}
 
     @param computeDefault: A 1-argument callable, which will be called with
         C{testCase} to compute a default value for the attribute for the given
         test if no custom one was specified.
+    @type computeDefault: L{callable}
+
+    @return: the value of the given C{attribute} for the given C{testCase}, as
+        decorated with C{withSpecialValue}.
+    @rtype: same type as the return type of L{computeDefault}
     """
     testID = testCase.id()
     testMethodName = testID.split(".")[-1]
@@ -305,6 +313,7 @@
 
 
 _SPECIAL_QUOTA = "__special_quota__"
+_SPECIAL_TXN_CLEAN = "__special_txn_clean__"
 
 
 
@@ -338,12 +347,29 @@
     Test method decorator that will cause L{deriveQuota} to return a different
     value for test cases that run that test method.
 
-    @see: withSpecialValue
+    @see: L{withSpecialValue}
     """
     return withSpecialValue(_SPECIAL_QUOTA, quotaValue)
 
 
 
+def transactionClean(f=None):
+    """
+    Test method decorator that will cause L{buildStore} to check that no
+    transactions were left outstanding at the end of the test, and fail the
+    test if they are outstanding rather than terminating them by shutting down
+    the connection pool service.
+
+    @see: L{withSpecialValue}
+    """
+    decorator = withSpecialValue(_SPECIAL_TXN_CLEAN, True)
+    if f:
+        return decorator(f)
+    else:
+        return decorator
+
+
+
 @inlineCallbacks
 def populateCalendarsFrom(requirements, store, migrating=False):
     """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121116/d4654c4b/attachment-0001.html>


More information about the calendarserver-changes mailing list