Here are the examples of the python api twisted.test.iosim.connectedServerAndClient taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
Example 1
Project: mythbox Source File: test_agent.py
def setUp(self):
# wire up our client <-> server
self.client, self.server, self.pump = iosim.connectedServerAndClient(
agent.SSHAgentServer, agent.SSHAgentClient)
# the server's end of the protocol is stateful and we store it on the
# factory, for which we only need a mock
self.server.factory = StubFactory()
# pub/priv keys of each kind
self.rsaPrivate = keys.Key.fromString(keydata.privateRSA_openssh)
self.dsaPrivate = keys.Key.fromString(keydata.privateDSA_openssh)
self.rsaPublic = keys.Key.fromString(keydata.publicRSA_openssh)
self.dsaPublic = keys.Key.fromString(keydata.publicDSA_openssh)
3
Example 2
def setUp(self):
AgentTestBase.setUp(self)
self.client, self.server, self.pump = iosim.connectedServerAndClient(
CorruptServer, agent.SSHAgentClient)
# the server's end of the protocol is stateful and we store it on the
# factory, for which we only need a mock
self.server.factory = StubFactory()
0
Example 3
Project: vertex Source File: helpers.py
def connectQ2Q(self, fromAddress, toAddress,
protocolName, protocolFactory,
chooser=lambda x: x and [x[0]]):
# XXX update this when q2q is updated to return a connector rather than
# a Deferred.
# XXX this isn't really dealing with the multiple-connectors use case
# now. sigma doesn't need this functionality, but we will need to
# update this class to do it properly before using it to test other Q2Q
# code.
listener, description = self.listeners.get((toAddress, protocolName))
if listener is None:
print 'void listener', fromAddress, toAddress, self.listeners, self.listener
reason = Failure(KeyError())
protocolFactory.clientConnectionFailed(None, reason)
return defer.fail(reason)
else:
def makeFakeClient(c):
ft = FakeQ2QTransport(c, False, fromAddress, toAddress)
return ft
def makeFakeServer(s):
ft = FakeQ2QTransport(s, True, toAddress, fromAddress)
return ft
client, server, pump = connectedServerAndClient(
lambda: listener.buildProtocol(fromAddress),
lambda: protocolFactory.buildProtocol(toAddress),
makeFakeClient,
makeFakeServer)
self.pumps.append(pump)
return defer.succeed(client)