def dispatch(self, method): class_name, method_name = method.split('.', 1) if class_name != "Test": raise JsonRpcMethodNotFoundError(method=method) try: return getattr(self, method_name) except AttributeError: raise JsonRpcMethodNotFoundError(method=method)
def test_missing_method(self): with self._create_client() as client: with self.assertRaises(ServerError) as ex: client.Test.missingMethod() self.assertEqual(ex.exception.code, JsonRpcMethodNotFoundError("").code) self.assertIn("missingMethod", ex.exception.resp_msg)
def testMethodMissingMethod(self, ssl): missing_method = "I_DO_NOT_EXIST :(" bridge = _DummyBridge() with constructClient(self.log, bridge, ssl) as clientFactory: with self._client(clientFactory) as client: with self.assertRaises(JsonRpcErrorBase) as cm: self._callTimeout(client, missing_method, [], CALL_ID) self.assertEqual( cm.exception.code, JsonRpcMethodNotFoundError(method=missing_method).code) self.assertIn(missing_method, cm.exception.message)
def dispatch(self, method): try: return getattr(self, method) except AttributeError: raise JsonRpcMethodNotFoundError(method=method)