[Zodb-checkins] CVS: Packages/ZEO - testZEO.py:1.1.2.4

jeremy@digicool.com jeremy@digicool.com
Thu, 19 Apr 2001 14:26:05 -0400 (EDT)


Update of /cvs-repository/Packages/ZEO/tests
In directory korak:/tmp/cvs-serv21302/tests

Modified Files:
      Tag: ZEO-ZRPC-Dev
	testZEO.py 
Log Message:
Fix uses of _get_serial() so that exceptions occur at the right time
and values really get returned.

17 or 19 tests now succeed



--- Updated File testZEO.py in package Packages/ZEO --
--- testZEO.py	2001/04/19 16:59:53	1.1.2.3
+++ testZEO.py	2001/04/19 18:26:05	1.1.2.4
@@ -68,25 +68,28 @@
         # Store an object
         r1 = self._storage.store(oid, revid, data, version,
                                  self._transaction)
+        s1 = self._get_serial(r1)
         # Finish the transaction
         r2 = self._storage.tpc_vote(self._transaction)
+        s2 = self._get_serial(r2)
         self._storage.tpc_finish(self._transaction)
-        return self._get_serial([r1, r2])[oid]
+        # s1, s2 can be None or dict
+        return s1 and s1[oid] or s2 and s2[oid]
 
-    def _get_serial(self, resps):
+    def _get_serial(self, r):
         """Return oid -> serialno dict from sequence of ZEO replies."""
         d = {}
-        for r in resps:
-            if not r:
-                continue
-            if type(r) == types.StringType:
-                raise RuntimeError, "unexpected ZEO response: no oid"
-            else:
-                for oid, serial in r:
-                    if type(serial) != types.StringType:
-                        raise s
-                    else:
-                        d[oid] = serial
+        zLOG.LOG('ZTB', zLOG.BLATHER, 'reply: %s' % repr(r))
+        if r is None:
+            return None
+        if type(r) == types.StringType:
+            raise RuntimeError, "unexpected ZEO response: no oid"
+        else:
+            for oid, serial in r:
+                if type(serial) != types.StringType:
+                    raise serial
+                else:
+                    d[oid] = serial
         return d
         
 class GenericTests(ZEOTestBase,