[Zodb-checkins] CVS: ZODB3/ZODB/tests - testCache.py:1.13

Jeremy Hylton jeremy@zope.com
Mon, 7 Apr 2003 18:26:05 -0400


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv25226/ZODB/tests

Modified Files:
	testCache.py 
Log Message:
Sync tests with current cache impl.


=== ZODB3/ZODB/tests/testCache.py 1.12 => 1.13 ===
--- ZODB3/ZODB/tests/testCache.py:1.12	Tue Apr  1 14:23:25 2003
+++ ZODB3/ZODB/tests/testCache.py	Mon Apr  7 18:26:04 2003
@@ -180,9 +180,14 @@
         for i in range(CONNS):
             self.noodle_new_connection()
 
-        # The DB cacheSize() method returns the number of non-ghost
-        # objects, which should be zero.
-        self.assertEquals(self.db.cacheSize(), 0)
+        self.assertEquals(self.db.cacheSize(), CACHE_SIZE * CONNS)
+        details = self.db.cacheDetailSize()
+        self.assertEquals(len(details), CONNS)
+        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):
         CACHE_SIZE = 10
@@ -192,15 +197,20 @@
         for i in range(CONNS):
             self.noodle_new_connection()
 
-        # the only thing in the cache is the root objects,
-        # which are referenced explicitly by the connection.
-        [(klass, count)] = self.db.cacheDetail()
-        self.assertEqual(klass, "Persistence.PersistentMapping")
-        self.assertEqual(count, CONNS)
+        for klass, count in self.db.cacheDetail():
+            if klass.endswith('MinPO'):
+                self.assertEqual(count, CONNS * CACHE_SIZE)
+            if klass.endswith('PersistentMapping'):
+                # one root per connection
+                self.assertEqual(count, CONNS)
 
         for details in self.db.cacheExtremeDetail():
-            self.assertEqual(details["klass"], "Persistence.PersistentMapping")
-            self.assertEqual(details['state'], None)
+            # one dict per object.  keys:
+            if details['klass'].endswith('PersistentMapping'):
+                self.assertEqual(details['state'], None)
+            else:
+                self.assert_(details['klass'].endswith('MinPO'))
+                self.assertEqual(details['state'], 0)
 
 class StubDataManager:
     def setklassstate(self, object):