[Zope-Checkins] CVS: Zope/lib/python/ZODB/tests - testFileStorage.py:1.19.6.5
Jeremy Hylton
jeremy@zope.com
Mon, 17 Mar 2003 14:52:23 -0500
Update of /cvs-repository/Zope/lib/python/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv19953/tests
Modified Files:
Tag: Zope-2_6-branch
testFileStorage.py
Log Message:
Backport: Fix use of RecordIterator() in fsrecover and add trivial test case.
=== Zope/lib/python/ZODB/tests/testFileStorage.py 1.19.6.4 => 1.19.6.5 ===
--- Zope/lib/python/ZODB/tests/testFileStorage.py:1.19.6.4 Thu Jan 30 18:25:19 2003
+++ Zope/lib/python/ZODB/tests/testFileStorage.py Mon Mar 17 14:51:52 2003
@@ -1,13 +1,29 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
from __future__ import nested_scopes
import sys, os, unittest
import time
import errno
+import filecmp
+import StringIO
import ZODB.FileStorage
from ZODB.referencesf import referencesf
from ZODB.Transaction import Transaction
from ZODB import POSException
+from ZODB.fsrecover import recover
from ZODB.tests import StorageTestBase, BasicStorage, \
TransactionalUndoStorage, VersionStorage, \
@@ -29,6 +45,7 @@
PackableStorage.PackableStorage,
Synchronization.SynchronizedStorage,
ConflictResolution.ConflictResolvingStorage,
+ ConflictResolution.ConflictResolvingTransUndoStorage,
HistoryStorage.HistoryStorage,
IteratorStorage.IteratorStorage,
IteratorStorage.ExtendedIteratorStorage,
@@ -38,12 +55,8 @@
):
def open(self, **kwargs):
- if kwargs:
- self._storage = apply(ZODB.FileStorage.FileStorage,
- ('FileStorageTests.fs',), kwargs)
- else:
- self._storage = ZODB.FileStorage.FileStorage(
- 'FileStorageTests.fs', **kwargs)
+ self._storage = ZODB.FileStorage.FileStorage('FileStorageTests.fs',
+ **kwargs)
def setUp(self):
self.open(create=1)
@@ -161,11 +174,29 @@
self._dostore()
self.failUnless(self._storage._records_before_save > 20)
+
+ def checkfsrecover(self):
+ # an absolutely minimal test of fsrecover
+ # Verify that calling recover on a small, correct storage
+ # produces a duplicate of the original.
+ for i in range(5):
+ oid = self._storage.new_oid()
+ revid = None
+ for j in range(5):
+ revid = self._dostore(oid, revid=revid)
+ temp = sys.stdout
+ sys.stdout = StringIO.StringIO()
+ try:
+ recover(["", "FileStorageTests.fs", "fsrecover.fs"])
+ finally:
+ sys.stdout = temp
+ self.assert_(filecmp.cmp("FileStorageTests.fs", "fsrecover.fs"))
+ StorageTestBase.removefs("fsrecover.fs")
class FileStorageRecoveryTest(
StorageTestBase.StorageTestBase,
- IteratorStorage.IteratorDeepCompare,
+ IteratorStorage.IteratorDeepCompare,
):
def setUp(self):