[Zodb-checkins] SVN: ZODB/trunk/src/ZEO/tests/servertesting.py Added helpers to make it a little easier ti set up servers and clients.

Jim Fulton jim at zope.com
Tue May 4 10:41:33 EDT 2010


Log message for revision 111923:
  Added helpers to make it a little easier ti set up servers and clients.
  

Changed:
  U   ZODB/trunk/src/ZEO/tests/servertesting.py

-=-
Modified: ZODB/trunk/src/ZEO/tests/servertesting.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/servertesting.py	2010-05-04 14:41:32 UTC (rev 111922)
+++ ZODB/trunk/src/ZEO/tests/servertesting.py	2010-05-04 14:41:33 UTC (rev 111923)
@@ -31,9 +31,15 @@
 import ZEO.StorageServer
 import ZEO.zrpc.connection
 import ZEO.zrpc.error
+import ZODB.MappingStorage
 
 class StorageServer(ZEO.StorageServer.StorageServer):
 
+    def __init__(self, addr='test_addr', storages=None, **kw):
+        if storages is None:
+            storages = {'1': ZODB.MappingStorage.MappingStorage()}
+        ZEO.StorageServer.StorageServer.__init__(self, addr, storages, **kw)
+
     def DispatcherClass(*args, **kw):
         pass
 
@@ -42,9 +48,10 @@
     peer_protocol_version = ZEO.zrpc.connection.Connection.current_protocol
     connected = True
 
-    def __init__(self, name='connection', addr='test-addr'):
+    def __init__(self, name='connection', addr=''):
+        name = str(name)
         self.name = name
-        self.addr = addr
+        self.addr = addr or 'test-addr-'+name
 
     def close(self):
         print self.name, 'closed'
@@ -65,3 +72,9 @@
 
     def send_reply(self, *args):
         pass
+
+def client(server, name='client', addr=''):
+    zs = ZEO.StorageServer.ZEOStorage(server)
+    zs.notifyConnected(Connection(name, addr))
+    zs.register('1', 0)
+    return zs



More information about the Zodb-checkins mailing list