[Zodb-checkins] CVS: ZODB3/ZODB/tests - testFileStorage.py:1.19.8.5

Jeremy Hylton jeremy@zope.com
Mon, 17 Mar 2003 14:39:15 -0500


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv18319/tests

Modified Files:
      Tag: ZODB3-3_1-branch
	testFileStorage.py 
Log Message:
Backport: Fix use of RecordIterator() in fsrecover and add trivial test case.


=== ZODB3/ZODB/tests/testFileStorage.py 1.19.8.4 => 1.19.8.5 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.19.8.4	Tue Jan  7 12:43:36 2003
+++ ZODB3/ZODB/tests/testFileStorage.py	Mon Mar 17 14:39:15 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):