Commit 26bdf792 authored by Jeremy Hylton's avatar Jeremy Hylton

Minimal fixes to make these tests work again.

The cache behaves differently now; it doesn't keep objects alive
artificially.  We should write some new tests that verify behavior
with objects that are kept alive by external references.
parent 5d66a163
...@@ -170,9 +170,6 @@ class LRUCacheTests(CacheTestBase): ...@@ -170,9 +170,6 @@ class LRUCacheTests(CacheTestBase):
# not bother to check this # not bother to check this
def checkSize(self): def checkSize(self):
# XXX need to fix
return
self.assertEqual(self.db.cacheSize(), 0) self.assertEqual(self.db.cacheSize(), 0)
self.assertEqual(self.db.cacheDetailSize(), []) self.assertEqual(self.db.cacheDetailSize(), [])
...@@ -183,19 +180,11 @@ class LRUCacheTests(CacheTestBase): ...@@ -183,19 +180,11 @@ class LRUCacheTests(CacheTestBase):
for i in range(CONNS): for i in range(CONNS):
self.noodle_new_connection() self.noodle_new_connection()
self.assertEquals(self.db.cacheSize(), CACHE_SIZE * CONNS) # The DB cacheSize() method returns the number of non-ghost
details = self.db.cacheDetailSize() # objects, which should be zero.
self.assertEquals(len(details), CONNS) self.assertEquals(self.db.cacheSize(), 0)
for d in details:
self.assertEquals(d['ngsize'], CACHE_SIZE)
# the root is also in the cache as ghost, because
# the connection holds a reference to it
self.assertEquals(d['size'], CACHE_SIZE + 1)
def checkDetail(self): def checkDetail(self):
# XXX need to fix
return
CACHE_SIZE = 10 CACHE_SIZE = 10
self.db.setCacheSize(CACHE_SIZE) self.db.setCacheSize(CACHE_SIZE)
...@@ -203,22 +192,15 @@ class LRUCacheTests(CacheTestBase): ...@@ -203,22 +192,15 @@ class LRUCacheTests(CacheTestBase):
for i in range(CONNS): for i in range(CONNS):
self.noodle_new_connection() self.noodle_new_connection()
for klass, count in self.db.cacheDetail(): # the only thing in the cache is the root objects,
print klass, count # which are referenced explicitly by the connection.
if klass.endswith('MinPO'): [(klass, count)] = self.db.cacheDetail()
self.assertEqual(count, CONNS * CACHE_SIZE) self.assertEqual(klass, "Persistence.PersistentMapping")
if klass.endswith('PersistentMapping'): self.assertEqual(count, CONNS)
# one root per connection
self.assertEqual(count, CONNS)
for details in self.db.cacheExtremeDetail(): for details in self.db.cacheExtremeDetail():
print details self.assertEqual(details["klass"], "Persistence.PersistentMapping")
# one dict per object. keys: self.assertEqual(details['state'], None)
if details['klass'].endswith('PersistentMapping'):
self.assertEqual(details['state'], None)
else:
self.assert_(details['klass'].endswith('MinPO'))
self.assertEqual(details['state'], 0)
class StubDataManager: class StubDataManager:
def setklassstate(self, object): def setklassstate(self, object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment