[CalendarServer-changes] [6355] CalendarServer/branches/users/glyph/more-deferreds-6/txdav

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 23 12:20:39 PDT 2010


Revision: 6355
          http://trac.macosforge.org/projects/calendarserver/changeset/6355
Author:   glyph at apple.com
Date:     2010-09-23 12:20:38 -0700 (Thu, 23 Sep 2010)
Log Message:
-----------
async-ish fixture population

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/test_sql.py
    CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py
    CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/test_sql.py	2010-09-23 19:19:50 UTC (rev 6354)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/caldav/datastore/test/test_sql.py	2010-09-23 19:20:38 UTC (rev 6355)
@@ -47,11 +47,12 @@
     def setUp(self):
         super(CalendarSQLStorageTests, self).setUp()
         self._sqlCalendarStore = yield buildStore(self, self.notifierFactory)
-        self.populate()
+        yield self.populate()
 
 
+    @inlineCallbacks
     def populate(self):
-        populateCalendarsFrom(self.requirements, self.storeUnderTest())
+        yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
         self.notifierFactory.reset()
 
 

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py	2010-09-23 19:19:50 UTC (rev 6354)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py	2010-09-23 19:20:38 UTC (rev 6355)
@@ -63,7 +63,7 @@
         )
         self.upgrader.setServiceParent(self.topService)
         requirements = CommonTests.requirements
-        populateCalendarsFrom(requirements, fileStore)
+        yield populateCalendarsFrom(requirements, fileStore)
         self.filesPath.child("calendars").child(
             "__uids__").child("ho").child("me").child("home1").child(
             ".some-extra-data").setContent("some extra data")
@@ -99,7 +99,7 @@
         """
         startTxn = self.sqlStore.newTransaction("populate empty sample")
         startTxn.calendarHomeWithUID("home1", create=True)
-        startTxn.commit()
+        yield startTxn.commit()
         self.topService.startService()
         yield self.subStarted
         vrfyTxn = self.sqlStore.newTransaction("verify sample still empty")
@@ -122,7 +122,7 @@
         def maybeCommit():
             if not committed:
                 committed.append(True)
-                txn.commit()
+                return txn.commit()
         self.addCleanup(maybeCommit)
         @inlineCallbacks
         def getSampleObj():

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py	2010-09-23 19:19:50 UTC (rev 6354)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/util.py	2010-09-23 19:20:38 UTC (rev 6355)
@@ -28,7 +28,7 @@
 from twext.python.vcomponent import VComponent
 
 from twisted.internet import reactor
-from twisted.internet.defer import Deferred, succeed
+from twisted.internet.defer import Deferred, succeed, inlineCallbacks
 from twisted.internet.task import deferLater
 from twisted.python import log
 
@@ -150,6 +150,7 @@
 buildStore = theStoreBuilder.buildStore
 
 
+ at inlineCallbacks
 def populateCalendarsFrom(requirements, store):
     """
     Populate C{store} from C{requirements}.
@@ -163,7 +164,7 @@
     for homeUID in requirements:
         calendars = requirements[homeUID]
         if calendars is not None:
-            home = populateTxn.calendarHomeWithUID(homeUID, True)
+            home = yield populateTxn.calendarHomeWithUID(homeUID, True)
             # We don't want the default calendar or inbox to appear unless it's
             # explicitly listed.
             try:
@@ -175,13 +176,13 @@
                 calendarObjNames = calendars[calendarName]
                 if calendarObjNames is not None:
                     home.createCalendarWithName(calendarName)
-                    calendar = home.calendarWithName(calendarName)
+                    calendar = yield home.calendarWithName(calendarName)
                     for objectName in calendarObjNames:
                         objData = calendarObjNames[objectName]
                         calendar.createCalendarObjectWithName(
                             objectName, VComponent.fromString(objData)
                         )
-    populateTxn.commit()
+    yield populateTxn.commit()
 
 
 def assertProvides(testCase, interface, provider):
@@ -230,8 +231,9 @@
         Commit the last transaction created from C{transactionUnderTest}, and
         clear it.
         """
-        self.lastTransaction.commit()
+        result = self.lastTransaction.commit()
         self.lastTransaction = None
+        return result
 
 
     def abort(self):
@@ -239,8 +241,9 @@
         Abort the last transaction created from C[transactionUnderTest}, and
         clear it.
         """
-        self.lastTransaction.abort()
+        result = self.lastTransaction.abort()
         self.lastTransaction = None
+        return result
 
     def setUp(self):
         self.counter = 0
@@ -248,7 +251,7 @@
 
     def tearDown(self):
         if self.lastTransaction is not None:
-            self.commit()
+            return self.commit()
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100923/c90952cd/attachment-0001.html>


More information about the calendarserver-changes mailing list