[CalendarServer-changes] [5913] CalendarServer/branches/new-store

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 19 15:30:54 PDT 2010


Revision: 5913
          http://trac.macosforge.org/projects/calendarserver/changeset/5913
Author:   glyph at apple.com
Date:     2010-07-19 15:30:53 -0700 (Mon, 19 Jul 2010)
Log Message:
-----------
tests and a good name for for duplicate-commit-and-abort exception

Modified Paths:
--------------
    CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py
    CalendarServer/branches/new-store/txcarddav/addressbookstore/test/common.py
    CalendarServer/branches/new-store/txdav/datastore/file.py
    CalendarServer/branches/new-store/txdav/idav.py

Modified: CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py	2010-07-19 20:59:34 UTC (rev 5912)
+++ CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py	2010-07-19 22:30:53 UTC (rev 5913)
@@ -14,7 +14,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-from twext.web2.http_headers import MimeType
 
 """
 Tests for common calendar store API functions.
@@ -27,7 +26,7 @@
 from twisted.internet.defer import Deferred, inlineCallbacks
 from twisted.internet.protocol import Protocol
 
-from txdav.idav import IPropertyStore, IDataStore
+from txdav.idav import IPropertyStore, IDataStore, AlreadyFinishedError
 from txdav.propertystore.base import PropertyName
 
 from txdav.common.icommondatastore import HomeChildNameAlreadyExistsError, \
@@ -43,6 +42,7 @@
 
 from twext.python.filepath import CachingFilePath as FilePath
 from twext.web2.dav import davxml
+from twext.web2.http_headers import MimeType
 from twext.web2.dav.element.base import WebDAVUnknownElement
 from twext.python.vcomponent import VComponent
 
@@ -1012,3 +1012,16 @@
             set(home1_calendarNames))
 
 
+    def test_finishedOnCommit(self):
+        """ 
+        Calling L{ITransaction.abort} or L{ITransaction.commit} after
+        L{ITransaction.commit} has already been called raises an
+        L{AlreadyFinishedError}.
+        """
+        self.calendarObjectUnderTest()
+        txn = self.lastTransaction
+        self.commit()
+        self.assertRaises(AlreadyFinishedError, txn.commit)
+        self.assertRaises(AlreadyFinishedError, txn.abort)
+
+

Modified: CalendarServer/branches/new-store/txcarddav/addressbookstore/test/common.py
===================================================================
--- CalendarServer/branches/new-store/txcarddav/addressbookstore/test/common.py	2010-07-19 20:59:34 UTC (rev 5912)
+++ CalendarServer/branches/new-store/txcarddav/addressbookstore/test/common.py	2010-07-19 22:30:53 UTC (rev 5913)
@@ -124,12 +124,12 @@
 
     def storeUnderTest(self):
         """
-        Subclasses must override this to return an L{IAddressBookStore} provider
-        which adheres to the structure detailed by L{CommonTests.requirements}.
-        This attribute is a dict of dict of dicts; the outermost layer
-        representing UIDs mapping to addressbook homes, then addressbook names mapping
-        to addressbook collections, and finally addressbook object names mapping to
-        addressbook object text.
+        Subclasses must override this to return an L{IAddressBookStore}
+        provider which adheres to the structure detailed by
+        L{CommonTests.requirements}. This attribute is a dict of dict of dicts;
+        the outermost layer representing UIDs mapping to addressbook homes,
+        then addressbook names mapping to addressbook collections, and finally
+        addressbook object names mapping to addressbook object text.
         """
         raise NotImplementedError()
 
@@ -351,7 +351,7 @@
         """
         L{IAddressBookHome.createAddressBookWithName} raises
         L{AddressBookAlreadyExistsError} when the name conflicts with an already-
-        existing 
+        existing address book.
         """
         for name in home1_addressbookNames:
             self.assertRaises(
@@ -751,7 +751,7 @@
         propertyContent = WebDAVUnknownElement("sample content")
         propertyContent.name = propertyName.name
         propertyContent.namespace = propertyName.namespace
-        
+
         self.addressbookObjectUnderTest().properties()[
             propertyName] = propertyContent
         self.commit()

Modified: CalendarServer/branches/new-store/txdav/datastore/file.py
===================================================================
--- CalendarServer/branches/new-store/txdav/datastore/file.py	2010-07-19 20:59:34 UTC (rev 5912)
+++ CalendarServer/branches/new-store/txdav/datastore/file.py	2010-07-19 22:30:53 UTC (rev 5913)
@@ -1,4 +1,4 @@
-# -*- test-case-name: txdav.datastore.test.test_file -*-
+# -*- test-case-name: txdav -*-
 ##
 # Copyright (c) 2010 Apple Inc. All rights reserved.
 #
@@ -21,6 +21,7 @@
 """
 
 from twext.python.log import LoggingMixIn
+from txdav.idav import AlreadyFinishedError
 
 def isValidName(name):
     """
@@ -168,10 +169,11 @@
         
         @type mode: C{str}
 
-        @raise RuntimeError: This transaction has already been terminated.
+        @raise AlreadyFinishedError: This transaction has already been
+            terminated.
         """
         if self._termination is not None:
-            raise RuntimeError("already %s" % (self._termination,))
+            raise AlreadyFinishedError("already %s" % (self._termination,))
         self._termination = mode
         self._tracker.done = True
 

Modified: CalendarServer/branches/new-store/txdav/idav.py
===================================================================
--- CalendarServer/branches/new-store/txdav/idav.py	2010-07-19 20:59:34 UTC (rev 5912)
+++ CalendarServer/branches/new-store/txdav/idav.py	2010-07-19 22:30:53 UTC (rev 5913)
@@ -21,14 +21,13 @@
 __all__ = [
     "PropertyStoreError",
     "PropertyChangeNotAllowedError",
-    "AbortedTransactionError",
+    "AlreadyFinishedError",
     "IPropertyName",
     "IPropertyStore",
     "IDataStore",
 ]
 
 from zope.interface import Attribute, Interface
-
 from zope.interface.common.mapping import IMapping
 
 #
@@ -41,6 +40,7 @@
     """
 
 
+
 class PropertyChangeNotAllowedError(PropertyStoreError):
     """
     Property cannot be edited.
@@ -50,9 +50,11 @@
         self.keys = keys
 
 
-class AbortedTransactionError(RuntimeError):
+
+class AlreadyFinishedError(Exception):
     """
-    This transaction has aborted.
+    The transaction was already completed via an C{abort} or C{commit} and
+    cannot be aborted or committed again.
     """
 
 
@@ -127,10 +129,16 @@
     def abort():
         """
         Abort this transaction.
+
+        @raise AlreadyFinishedError: The transaction was already finished with
+            an 'abort' or 'commit' and cannot be aborted again.
         """
 
 
     def commit():
         """
         Perform this transaction.
+
+        @raise AlreadyFinishedError: The transaction was already finished with
+            an 'abort' or 'commit' and cannot be committed again.
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100719/3069337b/attachment-0001.html>


More information about the calendarserver-changes mailing list