[CalendarServer-changes] [6354] CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/ propertystore/test

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 23 12:19:51 PDT 2010


Revision: 6354
          http://trac.macosforge.org/projects/calendarserver/changeset/6354
Author:   glyph at apple.com
Date:     2010-09-23 12:19:50 -0700 (Thu, 23 Sep 2010)
Log Message:
-----------
support async commit in setUp/tearDown (and replace ad-hoc _preTest/_postTest hooks with regular setUp/tearDown)

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

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/base.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/base.py	2010-09-23 19:00:53 UTC (rev 6353)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/base.py	2010-09-23 19:19:50 UTC (rev 6354)
@@ -38,10 +38,6 @@
 class PropertyStoreTest(unittest.TestCase):
     # Subclass must define self.propertyStore in setUp().
 
-    def _preTest(self):
-        self.addCleanup(self._postTest)
-    def _postTest(self):
-        pass
     def _changed(self, store):
         store.flush()
     def _abort(self, store):
@@ -49,14 +45,11 @@
 
     def test_interface(self):
         try:
-            self._preTest()
             verifyObject(IPropertyStore, self.propertyStore)
         except BrokenMethodImplementation, e:
             self.fail(e)
 
     def test_set_get_contains(self):
-        
-        self._preTest()
 
         name = propertyName("test")
         value = propertyValue("Hello, World!")
@@ -75,8 +68,6 @@
 
     def test_delete_get_contains(self):
 
-        self._preTest()
-
         # Test with commit after change
         name = propertyName("test")
         value = propertyValue("Hello, World!")
@@ -104,8 +95,6 @@
 
     def test_peruser(self):
 
-        self._preTest()
-
         name = propertyName("test")
         value1 = propertyValue("Hello, World1!")
         value2 = propertyValue("Hello, World2!")
@@ -140,8 +129,6 @@
         
     def test_peruser_shadow(self):
 
-        self._preTest()
-
         name = propertyName("shadow")
 
         self.propertyStore1.setSpecialProperties((name,), ())
@@ -181,8 +168,6 @@
 
     def test_peruser_global(self):
 
-        self._preTest()
-
         name = propertyName("global")
 
         self.propertyStore1.setSpecialProperties((), (name,))
@@ -215,8 +200,6 @@
 
     def test_iteration(self):
 
-        self._preTest()
-
         value = propertyValue("Hello, World!")
 
         names = set(propertyName(str(i)) for i in (1,2,3,4))
@@ -229,7 +212,6 @@
 
     def test_delete_none(self):
 
-        self._preTest()
         def doDelete():
             del self.propertyStore[propertyName("xyzzy")]
 
@@ -237,7 +219,6 @@
 
     def test_keyInPropertyName(self):
 
-        self._preTest()
 
         def doGet():
             self.propertyStore["xyzzy"]
@@ -258,8 +239,6 @@
 
     def test_flush(self):
 
-        self._preTest()
-
         name = propertyName("test")
         value = propertyValue("Hello, World!")
 
@@ -286,9 +265,6 @@
         self.assertEquals(len(self.propertyStore), 0)
 
     def test_abort(self):
-
-        self._preTest()
-
         name = propertyName("test")
         value = propertyValue("Hello, World!")
 

Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/test_sql.py	2010-09-23 19:00:53 UTC (rev 6353)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/base/propertystore/test/test_sql.py	2010-09-23 19:19:50 UTC (rev 6354)
@@ -19,7 +19,7 @@
 L{txdav.caldav.datastore.test.common}.
 """
 
-from twisted.internet.defer import inlineCallbacks
+from twisted.internet.defer import inlineCallbacks, returnValue
 
 from txdav.common.datastore.test.util import buildStore, StubNotifierFactory
 
@@ -36,23 +36,30 @@
 
 class PropertyStoreTest(base.PropertyStoreTest):
 
-    def _preTest(self):
+
+    @inlineCallbacks
+    def setUp(self):
+        self.notifierFactory = StubNotifierFactory()
+        self.store = yield buildStore(self, self.notifierFactory)
         self._txn = self.store.newTransaction()
         self.propertyStore = self.propertyStore1 = PropertyStore(
             "user01", self._txn, 1
         )
         self.propertyStore2 = PropertyStore("user01", self._txn, 1)
         self.propertyStore2._setPerUserUID("user02")
-        
-        self.addCleanup(self._postTest)
 
-    def _postTest(self):
+
+    @inlineCallbacks
+    def tearDown(self):
         if hasattr(self, "_txn"):
-            result = self._txn.commit()
+            result = yield self._txn.commit()
             delattr(self, "_txn")
+        else:
+            result = None
         self.propertyStore = self.propertyStore1 = self.propertyStore2 = None
-        return result
+        returnValue(result)
 
+
     def _changed(self, store):
         if hasattr(self, "_txn"):
             self._txn.commit()
@@ -72,6 +79,7 @@
         self.propertyStore2._shadowableKeys = store._shadowableKeys
         self.propertyStore2._globalKeys = store._globalKeys
 
+
     def _abort(self, store):
         if hasattr(self, "_txn"):
             self._txn.abort()
@@ -92,11 +100,8 @@
         self.propertyStore2._shadowableKeys = store._shadowableKeys
         self.propertyStore2._globalKeys = store._globalKeys
 
-    @inlineCallbacks
-    def setUp(self):
-        self.notifierFactory = StubNotifierFactory()
-        self.store = yield buildStore(self, self.notifierFactory)
 
+
 if PropertyStore is None:
     PropertyStoreTest.skip = importErrorMessage
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100923/f6e3d508/attachment.html>


More information about the calendarserver-changes mailing list