[Checkins] SVN: relstorage/trunk/ Increased automated test coverage
Shane Hathaway
shane at hathawaymix.org
Sat Jan 24 19:47:06 EST 2009
Log message for revision 94993:
Increased automated test coverage
Changed:
U relstorage/trunk/CHANGES.txt
A relstorage/trunk/relstorage/tests/fakecache.py
U relstorage/trunk/relstorage/tests/reltestbase.py
-=-
Modified: relstorage/trunk/CHANGES.txt
===================================================================
--- relstorage/trunk/CHANGES.txt 2009-01-25 00:46:35 UTC (rev 94992)
+++ relstorage/trunk/CHANGES.txt 2009-01-25 00:47:06 UTC (rev 94993)
@@ -7,7 +7,11 @@
- Began using zc.buildout for development.
+- Increased automated test coverage.
+- Fixed KeyError reporting to not trip over a related KeyError while logging.
+
+
Version 1.1.1 (2008-12-27)
- Worked around MySQL performance bugs in packing. Used temporary
Added: relstorage/trunk/relstorage/tests/fakecache.py
===================================================================
--- relstorage/trunk/relstorage/tests/fakecache.py (rev 0)
+++ relstorage/trunk/relstorage/tests/fakecache.py 2009-01-25 00:47:06 UTC (rev 94993)
@@ -0,0 +1,27 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""A memcache-like module sufficient for testing without an actual memcache.
+"""
+
+class Client(object):
+
+ def __init__(self, servers):
+ self.servers = servers
+ self.data = {}
+
+ def get(self, key):
+ return self.data.get(key)
+
+ def set(self, key, value):
+ self.data[key] = value
Modified: relstorage/trunk/relstorage/tests/reltestbase.py
===================================================================
--- relstorage/trunk/relstorage/tests/reltestbase.py 2009-01-25 00:46:35 UTC (rev 94992)
+++ relstorage/trunk/relstorage/tests/reltestbase.py 2009-01-25 00:47:06 UTC (rev 94993)
@@ -224,6 +224,33 @@
self.assertEqual(len(got), len(data))
self.assertEqual(got, data)
+ def checkLoadFromCache(self):
+ # Store an object, cache it, then retrieve it from the cache
+ self._storage._options.cache_servers = 'x:1 y:2'
+ self._storage._options.cache_module_name = 'relstorage.tests.fakecache'
+
+ db = DB(self._storage)
+ try:
+ c1 = db.open()
+ cache = c1._storage._cache_client
+ self.assertEqual(cache.servers, ['x:1', 'y:2'])
+ self.assertEqual(len(cache.data), 0)
+ r1 = c1.root()
+ self.assertEqual(len(cache.data), 2)
+ r1['alpha'] = PersistentMapping()
+ transaction.commit()
+ oid = r1['alpha']._p_oid
+
+ self.assertEqual(len(cache.data), 2)
+ got, serialno = c1._storage.load(oid, '')
+ self.assertEqual(len(cache.data), 4)
+ # load the object from the cache
+ got, serialno = c1._storage.load(oid, '')
+ # try to load an object that doesn't exist
+ self.assertRaises(KeyError, c1._storage.load, 'bad.oid.', '')
+ finally:
+ db.close()
+
def checkMultipleStores(self):
# Verify a connection can commit multiple transactions
db = DB(self._storage)
@@ -248,11 +275,14 @@
c1.close()
c1._storage._load_conn.close()
+ c1._storage._store_conn.close()
c2 = db.open()
self.assert_(c2 is c1)
r = c2.root()
self.assertEqual(r['alpha'], 1)
+ r['beta'] = 2
+ transaction.commit()
c2.close()
finally:
db.close()
@@ -260,7 +290,7 @@
def checkPollInterval(self):
# Verify the poll_interval parameter causes RelStorage to
# delay invalidation polling.
- self._storage._poll_interval = 3600
+ self._storage._options.poll_interval = 3600
db = DB(self._storage)
try:
c1 = db.open()
@@ -281,7 +311,10 @@
storage.tpc_vote(t)
storage.tpc_finish(t)
- # c2 should not see the change yet
+ # flush invalidations to c2, but the poll timer has not
+ # yet expired, so the change to r2 should not be seen yet.
+ self.assertTrue(c2._storage._poll_at > 0)
+ c2._flush_invalidations()
r2 = c2.root()
self.assertEqual(r2['alpha'], 1)
More information about the Checkins
mailing list