[Zodb-checkins] CVS: ZODB3/ZEO/tests - testConnection.py:1.4

Barry Warsaw barry@wooz.org
Tue, 10 Dec 2002 17:44:26 -0500


Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv28352

Modified Files:
	testConnection.py 
Log Message:
Refactor a bit to allow Berkeley storages to be included in these
tests, including read_only tests.


=== ZODB3/ZEO/tests/testConnection.py 1.3 => 1.4 ===
--- ZODB3/ZEO/tests/testConnection.py:1.3	Tue Dec 10 16:48:23 2002
+++ ZODB3/ZEO/tests/testConnection.py	Tue Dec 10 17:44:26 2002
@@ -36,13 +36,8 @@
 
     """Add Unix-specific scaffolding to the generic test suite."""
 
-    def startServer(self, create=1, index=0, read_only=0, ro_svr=0):
-        zLOG.LOG("testZEO", zLOG.INFO,
-                 "startServer(create=%d, index=%d, read_only=%d)" %
-                 (create, index, read_only))
-        path = "%s.%d" % (self.file, index)
-        addr = self.addr[index]
-        conf = """\
+    def getConfig(self, path, create, read_only):
+        return """\
         <Storage>
             type FileStorage
             file_name %s
@@ -52,6 +47,13 @@
                          create and 'yes' or 'no',
                          read_only and 'yes' or 'no')
 
+    def startServer(self, create=1, index=0, read_only=0, ro_svr=0):
+        zLOG.LOG("testZEO", zLOG.INFO,
+                 "startServer(create=%d, index=%d, read_only=%d)" %
+                 (create, index, read_only))
+        path = "%s.%d" % (self.file, index)
+        addr = self.addr[index]
+        conf = self.getConfig(path, create, read_only)
         pid, server = forker.start_zeo_server(conf, addr, ro_svr)
         self._pids.append(pid)
         self._servers.append(server)
@@ -66,6 +68,18 @@
             except os.error, err:
                 print err
 
+
+class BDBConnectionTests(UnixConnectionTests):
+    def getConfig(self, path, create, read_only):
+        # Full always creates and doesn't have a read_only flag
+        return """\
+        <Storage>
+            type Full
+            name %s
+            read_only %s
+        </Storage>""" % (path, read_only)
+
+
 class WindowsConnectionTests(ConnectionTests):
 
     """Add Windows-specific scaffolding to the generic test suite."""
@@ -92,6 +106,7 @@
             # XXX waitpid() isn't available until Python 2.3
             time.sleep(0.5)
 
+
 if os.name == "posix":
     test_classes = [UnixConnectionTests]
 elif os.name == "nt":
@@ -99,8 +114,15 @@
 else:
     raise RuntimeError, "unsupported os: %s" % os.name
 
-def test_suite():
+try:
+    from bsddb3Storage.Full import Full
+except ImportError:
+    pass
+else:
+    test_classes.append(BDBConnectionTests)
 
+
+def test_suite():
     # shutup warnings about mktemp
     import warnings
     warnings.filterwarnings("ignore", "mktemp")