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

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


Revision: 10063
          http://trac.calendarserver.org//changeset/10063
Author:   glyph at apple.com
Date:     2012-11-16 14:49:02 -0800 (Fri, 16 Nov 2012)
Log Message:
-----------
test to verify processing stops when there's a problem

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/one-home-list-api/txdav/caldav/datastore/test/common.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:01 UTC (rev 10062)
+++ CalendarServer/branches/users/glyph/one-home-list-api/txdav/caldav/datastore/test/common.py	2012-11-16 22:49:02 UTC (rev 10063)
@@ -2325,3 +2325,41 @@
                 None, (yield home.calendarWithName("a-new-calendar"))
             )
 
+
+    @inlineCallbacks
+    def test_withEachCalendarHomeDont(self):
+        """
+        When the function passed to L{ICalendarStore.withEachCalendarHomeDo}
+        raises an exception, processing is halted and the transaction is
+        aborted.  The exception is re-raised.
+        """
+        # create some calendar homes.
+        additionalUIDs = set('home2 home3'.split())
+        txn = self.transactionUnderTest()
+        for uid in additionalUIDs:
+            yield txn.calendarHomeWithUID(uid, create=True)
+        yield self.commit()
+        # try to create a calendar in all of them, then fail.
+        class AnException(Exception): pass
+        caught = []
+        @inlineCallbacks
+        def toEachCalendarHome(txn, eachHome):
+            caught.append(eachHome.uid())
+            yield eachHome.createCalendarWithName("wont-be-created")
+            raise AnException()
+        store = self.storeUnderTest()
+        yield self.failUnlessFailure(
+            store.withEachCalendarHomeDo(toEachCalendarHome), AnException
+        )
+        self.assertEquals(len(caught), 1)
+        @inlineCallbacks
+        def noNewCalendar(x):
+            home = yield txn.calendarHomeWithUID(uid, create=False)
+            self.assertIdentical(
+                (yield home.calendarWithName("wont-be-created")), None
+            )
+        txn = self.transactionUnderTest()
+        yield noNewCalendar(caught[0])
+        yield noNewCalendar('home2')
+        yield noNewCalendar('home3')
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121116/7d4099c4/attachment-0001.html>


More information about the calendarserver-changes mailing list