[Zodb-checkins] CVS: StandaloneZODB/ZODB/tests - IteratorStorage.py:1.5.4.1

Barry Warsaw barry@wooz.org
Wed, 23 Jan 2002 16:43:43 -0500


Update of /cvs-repository/StandaloneZODB/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv12874

Modified Files:
      Tag: Recovery
	IteratorStorage.py 
Log Message:
New class, IteratorDeepCompare, which implements a compare() method.
This iterates through two storage's iterator protocols, making sure
that every piece of public data is exactly the same, on both the
transaction records and the data records.  It also makes sure that the
iterators have exactly the same number of elements.

This is used to test copyTransactionsFrom().


=== StandaloneZODB/ZODB/tests/IteratorStorage.py 1.5 => 1.5.4.1 ===
         self.iter_verify(txniter, [revid3], 13)
         
+class IteratorDeepCompare:
+    def compare(self, storage1, storage2):
+        eq = self.assertEqual
+        iter1 = storage1.iterator()
+        iter2 = storage2.iterator()
+        for txn1, txn2 in zip(iter1, iter2):
+            eq(txn1.tid,         txn2.tid)
+            eq(txn1.status,      txn2.status)
+            eq(txn1.user,        txn2.user)
+            eq(txn1.description, txn2.description)
+            eq(txn1._extension,  txn2._extension)
+            for rec1, rec2 in zip(txn1, txn2):
+                eq(rec1.oid,     rec2.oid)
+                eq(rec1.serial,  rec2.serial)
+                eq(rec1.version, rec2.version)
+                eq(rec1.data,    rec2.data)
+            # Make sure there are no more records left in rec1 and rec2,
+            # meaning they were the same length.
+            self.assertRaises(IndexError, txn1.next)
+            self.assertRaises(IndexError, txn2.next)
+        # Make sure ther are no more records left in txn1 and txn2, meaning
+        # they were the same length
+        self.assertRaises(IndexError, iter1.next)
+        self.assertRaises(IndexError, iter2.next)