def test_rpc_server(self): node = Mock(spec=NodeB) svc = SimpleService() rpcs = RPCServer(node=node, from_name="testrpc", service=svc) # build a command object to be returned by the mocked channel class FakeMsg(object): def __init__(self): self.named = ["ein", "zwei"] cvalue = FakeMsg() listen_channel_mock = self._setup_mock_channel(ch_type=ServerChannel) rpcs.node.channel.return_value = listen_channel_mock # tell our channel to return a mocked handler channel when accepted (listen() implementation detail) listen_channel_mock.accept.return_value.__enter__.return_value = self._setup_mock_channel( ch_type=ServerChannel.BidirAcceptChannel, value=cvalue, op="simple" ) rpcs.listen() # wait for first message to get passed in ret = svc._ar.get() self.assertIsInstance(ret, list) self.assertEquals(ret, ["ein", "zwei"])
def test_rpc_server(self): node = Mock(spec=NodeB) svc = SimpleService() rpcs = RPCServer(node=node, from_name="testrpc", service=svc) node.interceptors = {} # build a command object to be returned by the mocked channel class FakeMsg(object): def __init__(self): self.named = ["ein", "zwei"] cvalue = FakeMsg() listen_channel_mock = self._setup_mock_channel(ch_type=ServerChannel) rpcs.node.channel.return_value = listen_channel_mock # tell our channel to return a mocked handler channel when accepted (listen() implementation detail) listen_channel_mock.accept.return_value = self._setup_mock_channel( ch_type=ServerChannel.BidirAcceptChannel, value=cvalue, op="simple") rpcs.listen() # wait for first message to get passed in ret = svc._ar.get() self.assertIsInstance(ret, list) self.assertEquals(ret, ["ein", "zwei"])
node,iowat=make_node() bs = BankService() rpcs = RPCServer(node=node, name="bank", service=bs) mooo=rpcs.listen() gevent.joinall([mooo]) """ """ from pyon.container.cc import Container cc=Container() cc.start() cc.start_rel_from_url('res/deploy/r2deploy.yml') cc.serve_forever() """ from pyon.net.endpoint import RPCServer from examples.service.hello_service import HelloService hs=HelloService() from pyon.net.messaging import make_node n,io=make_node() rpcs=RPCServer(service=hs, node=n, name=('qq', 'hello')) rpcs.listen()