def CreateRPC(self): """Creates RPC object instance. Returns: a instance of RPC. """ return apiproxy_rpc.RPC(stub=self)
def testMakeCallFailure(self): stub = MockStub(Exception()) rpc = apiproxy_rpc.RPC(stub=stub) rpc.MakeCall('test', 'method', 'request', 'response') rpc.Wait() self.assertRaises(Exception, rpc.CheckSuccess)
def CreateRPC(self): """ Create an RPC that can be used asynchronously. """ # If the runtime is importing a module, fall back to the non-threaded RPC. # This prevents a deadlock in cases when the RealRPC thread tries to # acquire the import lock. if imp.lock_held(): return apiproxy_rpc.RPC(stub=self) else: return apiproxy_rpc.RealRPC(stub=self)
def testClone(self): """Test that Clone behaves appropriately.""" stub = MockStub() deadline = 1.0 rpc = apiproxy_rpc.RPC(stub=stub, deadline=deadline) rpc_clone = rpc.Clone() self.assertEqual(rpc_clone.deadline, rpc.deadline) self.assertNotEqual(rpc_clone.MakeCall, rpc.MakeCall)
def testMakeCallSuccess(self): stub = MockStub() rpc = apiproxy_rpc.RPC(stub=stub) rpc.MakeCall('test', 'method', 'request', 'response') rpc.Wait() rpc.CheckSuccess() self.assertEquals([('test', 'method', 'request', 'response')], stub.calls)
def testMakeCallWithCallback(self): stub = MockStub() rpc = apiproxy_rpc.RPC(stub=stub) rpc.MakeCall('test', 'method', 'request', 'response', lambda: FakeCallback(stub)) rpc.Wait() rpc.CheckSuccess() self.assertEquals([('test', 'method', 'request', 'response'), ('callback')], stub.calls)
def testCloneAlreadyCalled(self): """Make sure we can't clone once we've started a call.""" stub = MockStub() rpc = apiproxy_rpc.RPC(stub=stub) rpc.MakeCall('test', 'method', 'request', 'response') self.assertRaises(AssertionError, rpc.Clone) rpc.Wait() self.assertRaises(AssertionError, rpc.Clone) rpc.CheckSuccess() self.assertRaises(AssertionError, rpc.Clone) self.assertEquals([('test', 'method', 'request', 'response')], stub.calls)
def CreateRPC(self): return apiproxy_rpc.RPC(stub=self)
def CreateRPC(self): """ Create an RPC that can be used asynchronously. """ if imp.lock_held(): return apiproxy_rpc.RPC(stub=self) else: return apiproxy_rpc.RealRPC(stub=self)
def CreateRPC(self): """Creates a (dummy) RPC object instance.""" return apiproxy_rpc.RPC(stub=self)