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

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <20100504144133.F04147083BD__19456.1209100813$1272984101$gmane$org@cvs.zope.org>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.