[Zope3-checkins] CVS: ZODB4/ZEO/tests - ConnectionTests.py:1.3

Barry Warsaw barry@wooz.org
Mon, 16 Dec 2002 18:10:58 -0500


Update of /cvs-repository/ZODB4/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv23390

Modified Files:
	ConnectionTests.py 
Log Message:
Refactor setup into a CommonSetupTearDown class so that we don't
accidently duplicate a bunch of the tests.

More conversion to booleans.


=== ZODB4/ZEO/tests/ConnectionTests.py 1.2 => 1.3 ===
--- ZODB4/ZEO/tests/ConnectionTests.py:1.2	Mon Dec 16 16:15:20 2002
+++ ZODB4/ZEO/tests/ConnectionTests.py	Mon Dec 16 18:10:57 2002
@@ -43,7 +43,7 @@
         pass
 
 
-class ConnectionTests(StorageTestBase):
+class CommonSetupTearDown(StorageTestBase):
     """Tests that explicitly manage the server process.
 
     To test the cache or re-connection, these test cases explicit
@@ -52,7 +52,6 @@
 
     __super_setUp = StorageTestBase.setUp
     __super_tearDown = StorageTestBase.tearDown
-    keep = False
 
     def setUp(self):
         """Test setup for connection tests.
@@ -99,8 +98,8 @@
     def getConfig(self):
         raise NotImplementedError
 
-    def openClientStorage(self, cache='', cache_size=200000, wait=1,
-                          read_only=0, read_only_fallback=0,
+    def openClientStorage(self, cache='', cache_size=200000, wait=True,
+                          read_only=False, read_only_fallback=False,
                           addr=None):
         if addr is None:
             addr = self.addr
@@ -155,6 +154,10 @@
             if now > giveup:
                 self.fail("timed out waiting for storage to disconnect")
 
+
+class ConnectionTests(CommonSetupTearDown):
+    keep = False
+
     def checkMultipleAddresses(self):
         for i in range(4):
             self._newAddr()
@@ -189,7 +192,7 @@
         # Open a read-only client to a read-write server; stores fail
 
         # Start a read-only client for a read-write server
-        self._storage = self.openClientStorage(read_only=1)
+        self._storage = self.openClientStorage(read_only=True)
         # Stores should fail here
         self.assertRaises(ReadOnlyError, self._dostore)
 
@@ -202,9 +205,9 @@
         self._pids = []
 
         # Start a read-only server
-        self.startServer(create=0, index=0, ro_svr=1)
+        self.startServer(create=False, index=0, ro_svr=True)
         # Start a read-only client
-        self._storage = self.openClientStorage(read_only=1)
+        self._storage = self.openClientStorage(read_only=True)
         # Stores should fail here
         self.assertRaises(ReadOnlyError, self._dostore)
 
@@ -212,7 +215,7 @@
         # Open a fallback client to a read-write server; stores succeed
 
         # Start a read-only-fallback client for a read-write server
-        self._storage = self.openClientStorage(read_only_fallback=1)
+        self._storage = self.openClientStorage(read_only_fallback=True)
         # Stores should succeed here
         self._dostore()
 
@@ -225,9 +228,9 @@
         self._pids = []
 
         # Start a read-only server
-        self.startServer(create=0, index=0, ro_svr=1)
+        self.startServer(create=False, index=0, ro_svr=True)
         # Start a read-only-fallback client
-        self._storage = self.openClientStorage(read_only_fallback=1)
+        self._storage = self.openClientStorage(read_only_fallback=True)
         # Stores should fail here
         self.assertRaises(ReadOnlyError, self._dostore)
 
@@ -253,7 +256,7 @@
         self.assertRaises(Disconnected, self._dostore)
 
         # Restart the server
-        self.startServer(create=0)
+        self.startServer(create=False)
         # Poll until the client connects
         self.pollUp()
         # Stores should succeed here
@@ -264,7 +267,7 @@
         # object when we're not connected to a storage server and the
         # object is not in the cache.
         self.shutdownServer()
-        self._storage = self.openClientStorage('test', 1000, wait=0)
+        self._storage = self.openClientStorage('test', 1000, wait=False)
         self.assertRaises(Disconnected, self._storage.load, 'fredwash', '')
 
     def checkBasicPersistence(self):
@@ -280,7 +283,7 @@
         revid1 = self._dostore(oid, data=obj)
         self._storage.close()
         self.shutdownServer()
-        self._storage = self.openClientStorage('test', 100000, wait=0)
+        self._storage = self.openClientStorage('test', 100000, wait=False)
         data, revid2 = self._storage.load(oid, '')
         self.assertEqual(zodb_unpickle(data), MinPO(12))
         self.assertEqual(revid1, revid2)
@@ -301,7 +304,7 @@
         self._dostore(oid2, data=obj2)
         self._storage.close()
         self.shutdownServer()
-        self._storage = self.openClientStorage('test', 1000, wait=0)
+        self._storage = self.openClientStorage('test', 1000, wait=False)
         self._storage.load(oid1, '')
         self._storage.load(oid2, '')
 
@@ -324,7 +327,7 @@
         self.shutdownServer()
         zLOG.LOG("checkReconnection", zLOG.INFO,
                  "About to restart server")
-        self.startServer(create=0)
+        self.startServer(create=False)
         oid = self._storage.new_oid()
         obj = MinPO(12)
         while 1:
@@ -420,7 +423,7 @@
                 t.closeclients()
 
 
-class ReconnectionTests(ConnectionTests):
+class ReconnectionTests(CommonSetupTearDown):
     keep = True
 
     def checkReadOnlyStorage(self):
@@ -432,9 +435,9 @@
         self._pids = []
 
         # Start a read-only server
-        self.startServer(create=0, index=0, read_only=1)
+        self.startServer(create=False, index=0, read_only=True)
         # Start a read-only client
-        self._storage = self.openClientStorage(read_only=1)
+        self._storage = self.openClientStorage(read_only=True)
         # Stores should fail here
         self.assertRaises(ReadOnlyError, self._dostore)
 
@@ -447,9 +450,9 @@
         self._pids = []
 
         # Start a read-only server
-        self.startServer(create=0, index=0, read_only=1)
+        self.startServer(create=False, index=0, read_only=True)
         # Start a read-only-fallback client
-        self._storage = self.openClientStorage(read_only_fallback=1)
+        self._storage = self.openClientStorage(read_only_fallback=True)
         # Stores should fail here
         self.assertRaises(ReadOnlyError, self._dostore)
 
@@ -458,7 +461,7 @@
         # read-only server
 
         # Start a client
-        self._storage = self.openClientStorage(read_only=1)
+        self._storage = self.openClientStorage(read_only=True)
         # Stores should fail here
         self.assertRaises(ReadOnlyError, self._dostore)
 
@@ -472,7 +475,7 @@
         self.assertRaises(ReadOnlyError, self._dostore)
 
         # Restart the server
-        self.startServer(create=0, read_only=1)
+        self.startServer(create=False, read_only=True)
         # Poll until the client connects
         self.pollUp()
         # Stores should still fail
@@ -483,7 +486,7 @@
         # read-only server
 
         # Start a client in fallback mode
-        self._storage = self.openClientStorage(read_only_fallback=1)
+        self._storage = self.openClientStorage(read_only_fallback=True)
         # Stores should succeed here
         self._dostore()
 
@@ -497,7 +500,7 @@
         self.assertRaises(Disconnected, self._dostore)
 
         # Restart the server
-        self.startServer(create=0, read_only=1)
+        self.startServer(create=False, read_only=True)
         # Poll until the client connects
         self.pollUp()
         # Stores should fail here
@@ -513,7 +516,7 @@
         self._pids = []
 
         # Start a read-only server
-        self.startServer(create=0, read_only=1)
+        self.startServer(create=False, read_only=True)
         # Start a client in fallback mode
         self._storage = self.openClientStorage(read_only_fallback=1)
         # Stores should fail here
@@ -529,7 +532,7 @@
         self.assertRaises(Disconnected, self._dostore)
 
         # Restart the server, this time read-write
-        self.startServer(create=0)
+        self.startServer(create=False)
         # Poll until the client sconnects
         self.pollUp()
         # Stores should now succeed
@@ -548,14 +551,14 @@
         self._newAddr()
 
         # Start a read-only server
-        self.startServer(create=0, index=0, read_only=1)
+        self.startServer(create=False, index=0, read_only=True)
         # Start a client in fallback mode
-        self._storage = self.openClientStorage(read_only_fallback=1)
+        self._storage = self.openClientStorage(read_only_fallback=True)
         # Stores should fail here
         self.assertRaises(ReadOnlyError, self._dostore)
 
         # Start a read-write server
-        self.startServer(index=1, read_only=0)
+        self.startServer(index=1, read_only=False)
         # After a while, stores should work
         for i in range(300): # Try for 30 seconds
             try: