def testMethodReturnsNullAndServerReturnsTrue(self, rt, ssl): bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: res = self._callTimeout(client, "ping", [], apiTests.id, timeout=CALL_TIMEOUT) self.assertEquals(res, True)
def testMethodCallArgList(self, rt, ssl): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: self.assertEquals(self._callTimeout(client, "echo", (data,), apiTests.id, CALL_TIMEOUT), data)
def testMethodCallArgDict(self, rt, ssl): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: self.assertEquals( self._callTimeout(client, "echo", {'text': data}, apiTests.id, CALL_TIMEOUT), data)
def testMethodReturnsNull(self, reactorType): bridge = _DummyBridge() with constructServer(reactorType, bridge) as (server, clientFactory): client = clientFactory() client.connect() with closing(client): res = client.callMethod("ping", [], 10, timeout=CALL_TIMEOUT) self.assertEquals(res, None)
def testMethodMissingMethod(self, rt, ssl): bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: with self.assertRaises(JsonRpcError) as cm: self._callTimeout(client, "I.DO.NOT.EXIST :(", [], apiTests.id, CALL_TIMEOUT) self.assertEquals(cm.exception.code, JsonRpcMethodNotFoundError().code)
def testMethodCallArgList(self, rt, ssl): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: self.log.info("Calling 'echo'") self.assertEquals( self._callTimeout(client, "echo", (data, ), apiTests.id, CALL_TIMEOUT), data)
def testMethodCallArgDict(self, reactorType): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(reactorType, bridge) as (server, clientFactory): client = clientFactory() client.connect() with closing(client): self.assertEquals( client.callMethod("echo", {'text': data}, 10, CALL_TIMEOUT), data)
def testMethodCallArgList(self, reactorType): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(reactorType, bridge) as (server, clientFactory): client = clientFactory() client.connect() with closing(client): self.assertEquals(client.callMethod("echo", (data,), 10, CALL_TIMEOUT), data)
def testMethodMissingMethod(self, reactorType): bridge = _DummyBridge() with constructServer(reactorType, bridge) as (server, clientFactory): client = clientFactory() client.connect() with closing(client): with self.assertRaises(JsonRpcError) as cm: client.callMethod("I.DO.NOT.EXIST :(", [], 10, CALL_TIMEOUT) self.assertEquals(cm.exception.code, JsonRpcMethodNotFoundError().code)
def testMethodBadParameters(self, rt, ssl): # Without a schema the server returns an internal error bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: with self.assertRaises(JsonRpcError) as cm: self._callTimeout(client, "echo", [], apiTests.id, timeout=CALL_TIMEOUT) self.assertEquals(cm.exception.code, JsonRpcInternalError().code)
def testMethodBadParameters(self, reactorType): # Without a schema the server returns an internal error bridge = _DummyBridge() with constructServer(reactorType, bridge) as (server, clientFactory): client = clientFactory() client.connect() with closing(client): with self.assertRaises(JsonRpcError) as cm: client.callMethod("echo", [], 10, timeout=CALL_TIMEOUT) self.assertEquals(cm.exception.code, JsonRpcInternalError().code)