[Zodb-checkins] CVS: ZODB3/ZEO/tests - test_cache.py:1.1.2.3

Jeremy Hylton cvs-admin at zope.org
Tue Nov 11 10:32:39 EST 2003


Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv10222/ZEO/tests

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	test_cache.py 
Log Message:
Finish cache serialization code.  Fix problem with struct codes.
Write real equality tests in testSerialization().
Use sum() to implement __len__().
Remove unused and broken contents() method.


=== ZODB3/ZEO/tests/test_cache.py 1.1.2.2 => 1.1.2.3 ===
--- ZODB3/ZEO/tests/test_cache.py:1.1.2.2	Mon Nov 10 17:42:54 2003
+++ ZODB3/ZEO/tests/test_cache.py	Tue Nov 11 10:32:37 2003
@@ -88,12 +88,17 @@
         self.cache.invalidate(n1, "", n5)
         self.assertEqual(self.cache.loadNonCurrent(n1, n5),
                          (data1, n4, n4, n5))
+        self.assertEqual(self.cache.loadNonCurrent(n2, n4), None)
 
     def testException(self):
         self.assertRaises(ValueError,
                           self.cache.store,
                           n1, "version", n2, n2, n3, "data")
-
+        self.cache.store(n1, "", n2, n2, None, "data")
+        self.assertRaises(ValueError,
+                          self.cache.store,
+                          n1, "", n3, n3, None, "data")
+        
     def testEviction(self):
         # Manually override the current maxsize
         maxsize = self.cache.size = self.cache.dll.maxsize = 1245
@@ -111,14 +116,29 @@
         n = p64(50)
         self.cache.store(n, "", n, n, None, data[51])
         self.assert_(len(self.cache) < 51)
-        self.assert_(self.cache.dll.currentsize < maxsize)
+        self.assert_(self.cache.dll.currentsize <= maxsize)
+
+        # XXX Need to make sure eviction of non-current data
+        # and of version data are handled correctly.
 
     def testSerialization(self):
+        self.cache.store(n1, "", n2, n2, None, "data for n1")
+        self.cache.store(n2, "version", n2, n2, None, "version data for n2")
+        self.cache.store(n3, "", n3, n3, n4, "non-current data for n3")
+        self.cache.store(n3, "", n4, n4, n5, "more non-current data for n3")
         self.cache.path = tempfile.mktemp()
         self.cache._write()
 
         copy = ZEO.cache.ClientCache(self.cache.path)
         copy.open()
+
+        # Verify that internals of both objects are the same.
+        # Could also test that external API produces the same results.
+        eq = self.assertEqual
+        eq(len(copy), len(self.cache))
+        eq(copy.version, self.cache.version)
+        eq(copy.current, self.cache.current)
+        eq(copy.noncurrent, self.cache.noncurrent)
         
 def test_suite():
     return unittest.makeSuite(CacheTests)




More information about the Zodb-checkins mailing list