[CalendarServer-changes] [6340] CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/ test/test_wrapping.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 22 18:49:59 PDT 2010


Revision: 6340
          http://trac.macosforge.org/projects/calendarserver/changeset/6340
Author:   glyph at apple.com
Date:     2010-09-22 18:49:58 -0700 (Wed, 22 Sep 2010)
Log Message:
-----------
prepare test_wrapping for asynchrony on commit()

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py	2010-09-22 23:02:28 UTC (rev 6339)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/twistedcaldav/test/test_wrapping.py	2010-09-23 01:49:58 UTC (rev 6340)
@@ -111,11 +111,12 @@
             pass
         txn = self.calendarCollection._newStore.newTransaction()
         home = yield txn.calendarHomeWithUID(uid, True)
-        cal = home.calendarWithName("calendar")
+        cal = yield home.calendarWithName("calendar")
         cal.createCalendarObjectWithName(objectName, VComponent.fromString(objectText))
-        txn.commit()
+        yield txn.commit()
 
 
+    @inlineCallbacks
     def populateOneAddressBookObject(self, objectName, objectText):
         """
         Populate one addressbook object in the test user's addressbook.
@@ -134,13 +135,13 @@
         except:
             pass
         txn = self.addressbookCollection._newStore.newTransaction()
-        home = txn.addressbookHomeWithUID(uid, True)
-        adbk = home.addressbookWithName("addressbook")
+        home = yield txn.addressbookHomeWithUID(uid, True)
+        adbk = yield home.addressbookWithName("addressbook")
         if adbk is None:
-            home.createAddressBookWithName("addressbook")
-            adbk = home.addressbookWithName("addressbook")
+            yield home.createAddressBookWithName("addressbook")
+            adbk = yield home.addressbookWithName("addressbook")
         adbk.createAddressBookObjectWithName(objectName, VCComponent.fromString(objectText))
-        txn.commit()
+        yield txn.commit()
 
 
     requestUnderTest = None
@@ -172,7 +173,7 @@
         an associated transaction.  Commit that transaction to bring the
         filesystem into a consistent state.
         """
-        self.requestUnderTest._newStoreTransaction.commit()
+        return self.requestUnderTest._newStoreTransaction.commit()
 
 
     def requestForPath(self, path):
@@ -244,7 +245,7 @@
         L{CalendarHome} via C{newTransaction().calendarHomeWithUID}.
         """
         calDavFile = yield self.getResource("calendars/users/wsanchez/")
-        self.commit()
+        yield self.commit()
         assertProvides(self, ICalendarHome, calDavFile._newStoreHome)
 
 
@@ -259,7 +260,7 @@
         dropBoxResource = yield self.getResource(
             "calendars/users/wsanchez/dropbox"
         )
-        self.commit()
+        yield self.commit()
         self.assertIsInstance(dropBoxResource, DropboxCollection)
         dropboxHomeType = davxml.ResourceType.dropboxhome #@UndefinedVariable
         self.assertEquals(dropBoxResource.resourceType(),
@@ -278,7 +279,7 @@
         regularCalendarType = davxml.ResourceType.calendar #@UndefinedVariable
         self.assertEquals(calDavFile.resourceType(),
                           regularCalendarType)
-        self.commit()
+        yield self.commit()
 
 
     @inlineCallbacks
@@ -293,7 +294,7 @@
         calDavFile = yield self.getResource("calendars/users/wsanchez/frobozz")
         self.assertIsInstance(calDavFile, ProtoCalendarCollectionResource)
         calDavFile.createCalendarCollection()
-        self.commit()
+        yield self.commit()
 
 
     @inlineCallbacks
@@ -311,7 +312,7 @@
             self.assertIdentical(
                 getattr(calDavFile, "_newStoreCalendar", None), None
             )
-        self.commit()
+        yield self.commit()
 
 
     @inlineCallbacks
@@ -349,7 +350,7 @@
         calDavFileCalendar = yield self.getResource(
             "calendars/users/wsanchez/calendar/1.ics"
         )
-        self.commit()
+        yield self.commit()
         self.assertEquals(calDavFileCalendar._principalCollections,
                           frozenset([self.principalsResource]))
         self.assertEquals(calDavFileCalendar._associatedTransaction,
@@ -366,7 +367,7 @@
         calDavFileCalendar = yield self.getResource(
             "calendars/users/wsanchez/calendar/xyzzy.ics"
         )
-        self.commit()
+        yield self.commit()
         self.assertEquals(calDavFileCalendar._principalCollections,
                           frozenset([self.principalsResource]))
 
@@ -387,7 +388,7 @@
         via C{newTransaction().addressbookHomeWithUID}.
         """
         calDavFile = yield self.getResource("addressbooks/users/wsanchez/")
-        self.commit()
+        yield self.commit()
         assertProvides(self, IAddressBookHome, calDavFile._newStoreHome)
 
 
@@ -399,7 +400,7 @@
         create a corresponding L{AddressBook} via C{AddressBookHome.addressbookWithName}.
         """
         calDavFile = yield self.getResource("addressbooks/users/wsanchez/addressbook")
-        self.commit()
+        yield self.commit()
         self.assertEquals(calDavFile._principalCollections,
                           frozenset([self.principalsResource]))
 
@@ -416,7 +417,7 @@
         calDavFile = yield self.getResource("addressbooks/users/wsanchez/frobozz")
         self.assertIsInstance(calDavFile, ProtoAddressBookCollectionResource)
         calDavFile.createAddressBookCollection()
-        self.commit()
+        yield self.commit()
         self.assertEquals(calDavFile._principalCollections,
                           frozenset([self.principalsResource]))
 
@@ -428,11 +429,11 @@
         up on a L{CalDAVResource} representing a addressbook collection, a parallel
         L{AddressBookObject} will be created (with a matching FilePath).
         """
-        self.populateOneAddressBookObject("1.vcf", vcard4_text)
+        yield self.populateOneAddressBookObject("1.vcf", vcard4_text)
         calDavFileAddressBook = yield self.getResource(
             "addressbooks/users/wsanchez/addressbook/1.vcf"
         )
-        self.commit()
+        yield self.commit()
         self.assertEquals(calDavFileAddressBook._principalCollections,
                           frozenset([self.principalsResource]))
 
@@ -447,7 +448,7 @@
         calDavFileAddressBook = yield self.getResource(
             "addressbooks/users/wsanchez/addressbook/xyzzy.ics"
         )
-        self.commit()
+        yield self.commit()
         self.assertEquals(calDavFileAddressBook._principalCollections,
                           frozenset([self.principalsResource]))
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100922/ee3e18e9/attachment.html>


More information about the calendarserver-changes mailing list