[Zope-Checkins] CVS: StandaloneZODB/ZODB/tests - testfsIndex.py:1.4
Guido van Rossum
guido@python.org
Tue, 12 Feb 2002 17:33:39 -0500
Update of /cvs-repository/StandaloneZODB/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv13020/ZODB/tests
Added Files:
testfsIndex.py
Log Message:
More changes merging the StandaloneZODB-1.0 release branch into the
trunk. I'm *almost* done with the merge; the only file not yet merged
is FileStorage.py.
=== StandaloneZODB/ZODB/tests/testfsIndex.py 1.3 => 1.4 ===
+import unittest, sys
+from ZODB.fsIndex import fsIndex
+from ZODB.utils import p64
+
+
+class Test(unittest.TestCase):
+
+ def testInserts(self):
+ index=fsIndex()
+
+ for i in range(200):
+ index[p64(i*1000)]=(i*1000L+1)
+
+ for i in range(0,200):
+ self.assertEqual((i,index[p64(i*1000)]), (i,(i*1000L+1)))
+
+ self.assertEqual(len(index), 200)
+
+ key=p64(2000)
+
+ self.assertEqual(index.get(key), 2001)
+
+ key=p64(2001)
+ self.assertEqual(index.get(key), None)
+ self.assertEqual(index.get(key, ''), '')
+
+ # self.failUnless(len(index._data) > 1)
+
+ def testUpdate(self):
+ index=fsIndex()
+ d={}
+
+ for i in range(200):
+ d[p64(i*1000)]=(i*1000L+1)
+
+ index.update(d)
+
+ for i in range(400,600):
+ d[p64(i*1000)]=(i*1000L+1)
+
+ index.update(d)
+
+ for i in range(100, 500):
+ d[p64(i*1000)]=(i*1000L+2)
+
+ index.update(d)
+
+ self.assertEqual(index.get(p64(2000)), 2001)
+ self.assertEqual(index.get(p64(599000)), 599001)
+ self.assertEqual(index.get(p64(399000)), 399002)
+ self.assertEqual(len(index), 600)
+
+
+def test_suite():
+ loader=unittest.TestLoader()
+ return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+ unittest.TextTestRunner().run(test_suite())