[Zodb-checkins] CVS: ZODB3/ZODB/tests - IteratorStorage.py:1.15 testFileStorage.py:1.26
Jeremy Hylton
jeremy@zope.com
Fri, 3 Jan 2003 17:07:49 -0500
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv21352/ZODB/tests
Modified Files:
IteratorStorage.py testFileStorage.py
Log Message:
Merge ZODB3-fast-restart-branch to the trunk
=== ZODB3/ZODB/tests/IteratorStorage.py 1.14 => 1.15 ===
--- ZODB3/ZODB/tests/IteratorStorage.py:1.14 Fri Dec 6 16:16:27 2002
+++ ZODB3/ZODB/tests/IteratorStorage.py Fri Jan 3 17:07:45 2003
@@ -38,6 +38,7 @@
eq(zodb_unpickle(rec.data), MinPO(val))
val = val + 1
eq(val, val0 + len(revids))
+ txniter.close()
class IteratorStorage(IteratorCompare):
@@ -191,3 +192,5 @@
# they were the same length
self.assertRaises(IndexError, iter1.next)
self.assertRaises(IndexError, iter2.next)
+ iter1.close()
+ iter2.close()
=== ZODB3/ZODB/tests/testFileStorage.py 1.25 => 1.26 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.25 Thu Dec 5 19:00:52 2002
+++ ZODB3/ZODB/tests/testFileStorage.py Fri Jan 3 17:07:45 2003
@@ -72,6 +72,101 @@
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()
+ self._storage.close()
+ os.remove('FileStorageTests.fs.index')
+ self.open()
+ self.assertEqual(self._storage._saved, 1)
+
+
+ # This would make the unit tests too slow
+ # check_save_after_load_that_worked_hard(self)
+
+ def check_periodic_save_index(self):
+
+ # Check the basic algorithm
+ oldsaved = self._storage._saved
+ self._storage._records_before_save = 10
+ for i in range(4):
+ self._dostore()
+ self.assertEqual(self._storage._saved, oldsaved)
+ self._dostore()
+ self.assertEqual(self._storage._saved, oldsaved+1)
+
+ # Now make sure the parameter changes as we get bigger
+ for i in range(20):
+ self._dostore()
+
+ self.failUnless(self._storage._records_before_save > 20)
+
class FileStorageRecoveryTest(
StorageTestBase.StorageTestBase,
RecoveryStorage.RecoveryStorage,