[Zodb-checkins] CVS: ZODB3/ZODB/tests - testFileStorage.py:1.19.8.4
Jeremy Hylton
jeremy@zope.com
Tue, 7 Jan 2003 12:43:40 -0500
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv1665/ZODB/tests
Modified Files:
Tag: ZODB3-3_1-branch
testFileStorage.py
Log Message:
Enable BTree-based fsIndex.
=== ZODB3/ZODB/tests/testFileStorage.py 1.19.8.3 => 1.19.8.4 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.19.8.3 Wed Dec 18 16:20:27 2002
+++ ZODB3/ZODB/tests/testFileStorage.py Tue Jan 7 12:43:36 2003
@@ -67,7 +67,72 @@
else:
self.fail("expect long user field to raise error")
+ def check_use_fsIndex(self):
+ from ZODB.fsIndex import fsIndex
+
+ self.assertEqual(self._storage._index.__class__, fsIndex)
+
# XXX We could really use some tests for sanity checking
+
+ def check_conversion_to_fsIndex_not_if_readonly(self):
+
+ self.tearDown()
+
+ class OldFileStorage(ZODB.FileStorage.FileStorage):
+ def _newIndexes(self):
+ return {}, {}, {}, {}
+
+
+ from ZODB.fsIndex import fsIndex
+
+ # Hack FileStorage to create dictionary indexes
+ self._storage = OldFileStorage('FileStorageTests.fs')
+
+ self.assertEqual(type(self._storage._index), type({}))
+ for i in range(10):
+ self._dostore()
+
+ # Should save the index
+ self._storage.close()
+
+ self._storage = ZODB.FileStorage.FileStorage(
+ 'FileStorageTests.fs', read_only=1)
+ self.assertEqual(type(self._storage._index), type({}))
+
+ def check_conversion_to_fsIndex(self):
+
+ self.tearDown()
+
+ class OldFileStorage(ZODB.FileStorage.FileStorage):
+ def _newIndexes(self):
+ return {}, {}, {}, {}
+
+
+ from ZODB.fsIndex import fsIndex
+
+ # Hack FileStorage to create dictionary indexes
+ self._storage = OldFileStorage('FileStorageTests.fs')
+
+ self.assertEqual(type(self._storage._index), type({}))
+ for i in range(10):
+ self._dostore()
+
+ oldindex = self._storage._index.copy()
+
+ # Should save the index
+ self._storage.close()
+
+ self._storage = ZODB.FileStorage.FileStorage('FileStorageTests.fs')
+ self.assertEqual(self._storage._index.__class__, fsIndex)
+ self.failUnless(self._storage._used_index)
+
+ index = {}
+ for k, v in self._storage._index.items():
+ index[k] = v
+
+ self.assertEqual(index, oldindex)
+
+
def check_save_after_load_with_no_index(self):
for i in range(10):
self._dostore()