def clientConnected(protocol): proxy = txprotobuf.Proxy(TestService_Stub(protocol)) request = TestRequest() request.text = "proxycall" d = proxy.TestMethod(request) d.addCallback(lambda response: self.assertEquals(response.text, request.text)) return d
def clientConnected(protocol): proxy = txprotobuf.Proxy(TestService_Stub(protocol)) request = TestRequest() request.text = "proxycall" d = proxy.TestMethod(request) d.addCallback(lambda response: self.assertEquals( response.text, request.text)) return d
def clientConnected(protocol): protocol.service = ClientTestService() channel = self.service.factory.protocols[0] controller = txprotobuf.Controller() service = TestService_Stub(channel) request = TestRequest() request.text = "reverse" wait = Deferred() wait.addCallback(lambda response: self.assertEquals(response.text, request.text)) service.TestMethod(controller, request, wait.callback) return wait
def clientConnected(protocol): protocol.service = ClientTestService() channel = self.service.factory.protocols[0] controller = txprotobuf.Controller() service = TestService_Stub(channel) request = TestRequest() request.text = "reverse" wait = Deferred() wait.addCallback(lambda response: self.assertEquals( response.text, request.text)) service.TestMethod(controller, request, wait.callback) return wait
def callTestMethod(protocol): channel = protocol controller = txprotobuf.Controller() service = TestService_Stub(channel) requestFoo = TestRequest() requestFoo.text = "foo" waitFoo = Deferred() waitFoo.addCallback(lambda responseFoo: self.assertEquals(responseFoo.text, requestFoo.text)) service.TestMethod(controller, requestFoo, waitFoo.callback) requestBar = TestRequest() requestBar.text = "bar" waitBar = Deferred() waitBar.addCallback(lambda responseBar: self.assertEquals(responseBar.text, requestBar.text)) service.TestMethod(controller, requestBar, waitBar.callback) return DeferredList([waitFoo, waitBar])
def callTestMethod(protocol): channel = protocol controller = txprotobuf.Controller() service = TestService_Stub(channel) request = TestRequest() request.text = "foo" d = self.service.waitFromTestMethodCall() def checkTestMethodCalled(text): self.assertEquals(request.text, text) d.addCallback(checkTestMethodCalled) waitForMethodResponse = Deferred() d.addCallback(lambda x: waitForMethodResponse) waitForMethodResponse.addCallback(lambda response: self.assertEquals(request.text, response.text)) def callback(response): waitForMethodResponse.callback(response) service.TestMethod(controller, request, callback) return d
def callTestMethod(protocol): channel = protocol controller = txprotobuf.Controller() service = TestService_Stub(channel) request = TestRequest() request.text = "foo" d = self.service.waitFromTestMethodCall() def checkTestMethodCalled(text): self.assertEquals(request.text, text) d.addCallback(checkTestMethodCalled) waitForMethodResponse = Deferred() d.addCallback(lambda x: waitForMethodResponse) waitForMethodResponse.addCallback( lambda response: self.assertEquals(request.text, response.text )) def callback(response): waitForMethodResponse.callback(response) service.TestMethod(controller, request, callback) return d
def callTestMethod(protocol): channel = protocol controller = txprotobuf.Controller() service = TestService_Stub(channel) requestFoo = TestRequest() requestFoo.text = "foo" waitFoo = Deferred() waitFoo.addCallback(lambda responseFoo: self.assertEquals( responseFoo.text, requestFoo.text)) service.TestMethod(controller, requestFoo, waitFoo.callback) requestBar = TestRequest() requestBar.text = "bar" waitBar = Deferred() waitBar.addCallback(lambda responseBar: self.assertEquals( responseBar.text, requestBar.text)) service.TestMethod(controller, requestBar, waitBar.callback) return DeferredList([waitFoo, waitBar])