[Zope-Checkins] CVS: Zope/lib/python/ZODB/tests - testFileStorage.py:1.19.6.3 PersistentStorage.py:1.2.6.1 IteratorStorage.py:1.12.6.1
Jeremy Hylton
jeremy@zope.com
Wed, 18 Dec 2002 16:59:49 -0500
Update of /cvs-repository/Zope/lib/python/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv13244/lib/python/ZODB/tests
Modified Files:
Tag: Zope-2_6-branch
testFileStorage.py PersistentStorage.py IteratorStorage.py
Log Message:
Merge latest round of changes from ZODB3-3_1-branch
=== Zope/lib/python/ZODB/tests/testFileStorage.py 1.19.6.2 => 1.19.6.3 ===
--- Zope/lib/python/ZODB/tests/testFileStorage.py:1.19.6.2 Wed Dec 11 11:30:45 2002
+++ Zope/lib/python/ZODB/tests/testFileStorage.py Wed Dec 18 16:59:18 2002
@@ -67,6 +67,37 @@
else:
self.fail("expect long user field to raise error")
+ # XXX We could really use some tests for sanity checking
+ 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,
IteratorStorage.IteratorDeepCompare,
@@ -120,6 +151,7 @@
pass # iterate until we get the last one
data = trans[0]
self.assertRaises(IndexError, lambda i:trans[i], 1)
+ iter.close()
self.assertEqual(data.oid, oid)
self.assertEqual(data.data, None)
@@ -196,11 +228,13 @@
# copy the final transaction manually. even though there
# was a pack, the restore() ought to succeed.
- final = list(self._storage.iterator())[-1]
+ siter = self._storage.iterator()
+ final = list(siter)[-1]
self._dst.tpc_begin(final, final.tid, final.status)
for r in final:
self._dst.restore(r.oid, r.serial, r.data, r.version, r.data_txn,
final)
+ siter.close()
self._dst.tpc_vote(final)
self._dst.tpc_finish(final)
=== Zope/lib/python/ZODB/tests/PersistentStorage.py 1.2 => 1.2.6.1 ===
--- Zope/lib/python/ZODB/tests/PersistentStorage.py:1.2 Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/tests/PersistentStorage.py Wed Dec 18 16:59:18 2002
@@ -13,7 +13,6 @@
self._storage.new_oid = new_oid_wrapper
self._dostore()
- self._dostore('a')
oid = self._storage.new_oid()
revid = self._dostore(oid)
self._dostore(oid, revid, data=8, version='b')
=== Zope/lib/python/ZODB/tests/IteratorStorage.py 1.12 => 1.12.6.1 ===
--- Zope/lib/python/ZODB/tests/IteratorStorage.py:1.12 Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/tests/IteratorStorage.py Wed Dec 18 16:59:18 2002
@@ -25,6 +25,7 @@
eq(zodb_unpickle(rec.data), MinPO(val))
val = val + 1
eq(val, val0 + len(revids))
+ txniter.close()
class IteratorStorage(IteratorCompare):
@@ -168,3 +169,5 @@
# they were the same length
self.assertRaises(IndexError, iter1.next)
self.assertRaises(IndexError, iter2.next)
+ iter1.close()
+ iter2.close()