[CalendarServer-changes] [7255] CalendarServer/branches/users/glyph/subtransactions/txdav/base/ propertystore/test/test_sql.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 24 13:36:40 PDT 2011


Revision: 7255
          http://trac.macosforge.org/projects/calendarserver/changeset/7255
Author:   glyph at apple.com
Date:     2011-03-24 13:36:40 -0700 (Thu, 24 Mar 2011)
Log Message:
-----------
finally, the interesting test!  also: re-use propertyName/propertyValue implementation.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/subtransactions/txdav/base/propertystore/test/test_sql.py

Modified: CalendarServer/branches/users/glyph/subtransactions/txdav/base/propertystore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/glyph/subtransactions/txdav/base/propertystore/test/test_sql.py	2011-03-24 20:36:29 UTC (rev 7254)
+++ CalendarServer/branches/users/glyph/subtransactions/txdav/base/propertystore/test/test_sql.py	2011-03-24 20:36:40 UTC (rev 7255)
@@ -23,8 +23,8 @@
 
 from txdav.common.datastore.test.util import buildStore, StubNotifierFactory
 
-from txdav.base.propertystore.base import PropertyName
-from txdav.base.propertystore.test import base
+from txdav.base.propertystore.test.base import (
+    PropertyStoreTest, propertyName, propertyValue)
 
 from twistedcaldav import memcacher
 from twistedcaldav.config import config
@@ -32,12 +32,13 @@
 try:
     from txdav.base.propertystore.sql import PropertyStore
 except ImportError, e:
+    # XXX: when could this ever fail?
     PropertyStore = None
     importErrorMessage = str(e)
 
 
 
-class PropertyStoreTest(base.PropertyStoreTest):
+class PropertyStoreTest(PropertyStoreTest):
 
 
     @inlineCallbacks
@@ -111,10 +112,32 @@
         self.propertyStore2._globalKeys = store._globalKeys
 
 
+    @inlineCallbacks
+    def test_concurrentInsertion(self):
+        """
+        When two property stores set the same value, the last one to set it
+        should win.
+        """
+        pname = propertyName("concurrent")
+        pval1 = propertyValue("alpha")
+        pval2 = propertyValue("beta")
+        concurrentTxn = self.store.newTransaction()
+        self.addCleanup(concurrentTxn.abort)
+        concurrentPropertyStore = yield PropertyStore.load(
+            "user01", concurrentTxn, 1
+        )
+        concurrentPropertyStore[pname] = pval1
+        concurrentTxn.commit()
 
+        self.propertyStore[pname] = pval2
+        yield self._txn.commit()
+        self._txn = None
+        self._abort(self.propertyStore)
+        self.assertEquals(self.propertyStore[pname], pval2)
+
+
+
 if PropertyStore is None:
     PropertyStoreTest.skip = importErrorMessage
 
 
-def propertyName(name):
-    return PropertyName("http://calendarserver.org/ns/test/", name)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110324/77c58d6c/attachment-0001.html>


More information about the calendarserver-changes mailing list