当前位置: 首页>>代码示例>>Python>>正文


Python endpoint.RPCResponseEndpointUnit类代码示例

本文整理汇总了Python中pyon.net.endpoint.RPCResponseEndpointUnit的典型用法代码示例。如果您正苦于以下问题:Python RPCResponseEndpointUnit类的具体用法?Python RPCResponseEndpointUnit怎么用?Python RPCResponseEndpointUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RPCResponseEndpointUnit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_receive_bad_op

    def test_receive_bad_op(self):

        class FakeMsg(object):
            def __init__(self):
                self.named = ["ein", "zwei"]
        cvalue = FakeMsg()

        e = RPCResponseEndpointUnit(routing_obj=self, interceptors={})
        ch = self._setup_mock_channel(value=cvalue, op="no_exist")
        e.attach_channel(ch)

        self._do_listen(e)

        assert_called_once_with_header(self, ch.send, {'status_code':400,
                                                       'error_message':'Unknown op name: no_exist',
                                                       'conv-id': sentinel.conv_id,
                                                       'conv-seq': 2,
                                                       'protocol':'',
                                                       'performative': 'failure',
                                                       'language':'ion-r2',
                                                       'encoding':'msgpack',
                                                       'format':'list',
                                                       'receiver': ',',
                                                       'msg-rcvd':ANY,
                                                       'ts': sentinel.ts})
开发者ID:daf,项目名称:pyon,代码行数:25,代码来源:test_endpoint.py

示例2: test__get_sflow_manager_with_container

    def test__get_sflow_manager_with_container(self):
        Container.instance = None
        c = Container() # ensure an instance
        e = RPCResponseEndpointUnit(interceptors={})
        self.assertEquals(e._get_sflow_manager(), c.sflow_manager)

        Container.instance = None
开发者ID:daf,项目名称:pyon,代码行数:7,代码来源:test_endpoint.py

示例3: test_recv_bad_kwarg

    def test_recv_bad_kwarg(self):
        # we try to call simple with the kwarg "not_named" instead of the correct one
        class FakeMsg(object):
            def __init__(self):
                self.not_named = ["ein", "zwei"]
        cvalue = FakeMsg()

        e = RPCResponseEndpointUnit(routing_obj=self, interceptors={})
        ch = self._setup_mock_channel(value=cvalue, op="simple")
        e.attach_channel(ch)

        self._do_listen(e)

        # test to make sure send got called with our error
        assert_called_once_with_header(self, ch.send, {'status_code':400,
                                                       'error_message':'Argument not_named not present in op signature',
                                                       'conv-id': sentinel.conv_id,
                                                       'conv-seq': 2,
                                                       'protocol':'',
                                                       'performative': 'failure',
                                                       'language':'ion-r2',
                                                       'encoding':'msgpack',
                                                       'format':'NoneType',
                                                       'receiver': ',',
                                                       'msg-rcvd':ANY,
                                                       'ts': sentinel.ts})
开发者ID:daf,项目名称:pyon,代码行数:26,代码来源:test_endpoint.py

示例4: test_receive_bad_op

    def test_receive_bad_op(self):
        class FakeMsg(object):
            def __init__(self):
                self.named = ["ein", "zwei"]

        cvalue = FakeMsg()

        e = RPCResponseEndpointUnit(routing_obj=self)
        ch = self._setup_mock_channel(value=cvalue, op="no_exist")
        e.attach_channel(ch)

        e.spawn_listener()
        e._recv_greenlet.join()

        # test to make sure send got called with our error
        ch.send.assert_called_once_with(
            None,
            {
                "status_code": 400,
                "error_message": "Unknown op name: no_exist",
                "conv-id": "",
                "conv-seq": 2,
                "protocol": "",
                "performative": "failure",
                "language": "ion-r2",
                "encoding": "msgpack",
                "format": "NoneType",
                "receiver": ",",
                "ts": sentinel.ts,
                "reply-by": "todo",
            },
        )
开发者ID:ooici-dm,项目名称:pyon,代码行数:32,代码来源:test_endpoint.py

示例5: test_recv_bad_kwarg

    def test_recv_bad_kwarg(self):
        # we try to call simple with the kwarg "not_named" instead of the correct one
        class FakeMsg(object):
            def __init__(self):
                self.not_named = ["ein", "zwei"]

        cvalue = FakeMsg()

        e = RPCResponseEndpointUnit(routing_obj=self)
        ch = self._setup_mock_channel(value=cvalue, op="simple")
        e.attach_channel(ch)

        e.spawn_listener()
        e._recv_greenlet.join()

        # test to make sure send got called with our error
        ch.send.assert_called_once_with(
            None,
            {
                "status_code": 500,
                "error_message": "simple() got an unexpected keyword argument 'not_named'",
                "conv-id": "",
                "conv-seq": 2,
                "protocol": "",
                "performative": "failure",
                "language": "ion-r2",
                "encoding": "msgpack",
                "format": "NoneType",
                "receiver": ",",
                "ts": sentinel.ts,
                "reply-by": "todo",
            },
        )
开发者ID:ooici-dm,项目名称:pyon,代码行数:33,代码来源:test_endpoint.py

示例6: test_recv_bad_kwarg

    def test_recv_bad_kwarg(self):
        # we try to call simple with the kwarg "not_named" instead of the correct one
        class FakeMsg(object):
            def __init__(self):
                self.not_named = ["ein", "zwei"]
        cvalue = FakeMsg()

        e = RPCResponseEndpointUnit(routing_obj=self)
        ch = self._setup_mock_channel(value=cvalue, op="simple")
        e.attach_channel(ch)

        e.spawn_listener()
        e._recv_greenlet.join()

        # test to make sure send got called with our error
        ch.send.assert_called_once_with(None, {'status_code':500,
                                               'error_message':'simple() got an unexpected keyword argument \'not_named\'',
                                               'conv-id': '',
                                               'conv-seq': 2,
                                               'protocol':'',
                                               'performative': 'failure',
                                               'language':'ion-r2',
                                               'encoding':'msgpack',
                                               'format':'NoneType',
                                               'receiver': ',',
                                               'reply-by': 'todo'})
开发者ID:tgiguere,项目名称:pyon,代码行数:26,代码来源:test_endpoint.py

示例7: test_receive_bad_op

    def test_receive_bad_op(self):

        class FakeMsg(object):
            def __init__(self):
                self.named = ["ein", "zwei"]
        cvalue = FakeMsg()

        e = RPCResponseEndpointUnit(routing_obj=self)
        ch = self._setup_mock_channel(value=cvalue, op="no_exist")
        e.attach_channel(ch)

        e.spawn_listener()
        e._recv_greenlet.join()

        # test to make sure send got called with our error
        ch.send.assert_called_once_with(None, {'status_code':400,
                                               'error_message':'Unknown op name: no_exist',
                                               'conv-id': '',
                                               'conv-seq': 2,
                                               'protocol':'',
                                               'performative': 'failure',
                                               'language':'ion-r2',
                                               'encoding':'msgpack',
                                               'format':'NoneType',
                                               'receiver': ',',
                                               'reply-by': 'todo'})
开发者ID:tgiguere,项目名称:pyon,代码行数:26,代码来源:test_endpoint.py

示例8: test_message_received_dict

    def test_message_received_dict(self):
        rout_obj = Mock()
        e = RPCResponseEndpointUnit(routing_obj=rout_obj)

        msg_dict = {"iam": "adict"}
        e.message_received(msg_dict, {"op": "anyop"})

        rout_obj.anyop.assert_called_once_with(iam="adict")
开发者ID:ooici-dm,项目名称:pyon,代码行数:8,代码来源:test_endpoint.py

示例9: test_message_received_dict

    def test_message_received_dict(self):
        rout_obj = Mock()
        e = RPCResponseEndpointUnit(routing_obj=rout_obj)

        msg_dict = {'iam':'adict'}
        e.message_received(msg_dict, {'op':'anyop'})

        rout_obj.anyop.assert_called_once_with(iam='adict')
开发者ID:daf,项目名称:pyon,代码行数:8,代码来源:test_endpoint.py

示例10: test__sample_request_no_sample

    def test__sample_request_no_sample(self, mocklog):
        e = RPCResponseEndpointUnit(interceptors={})

        e._get_sflow_manager = Mock(return_value=Mock(spec=SFlowManager))
        e._get_sflow_manager.return_value.should_sample = False
        e._get_sample_name = Mock()

        e._sample_request(sentinel.status, sentinel.status_descr, sentinel.msg, sentinel.headers, sentinel.response, sentinel.response_headers)

        self.assertEquals(mocklog.debug.call_count, 1)
        self.assertIn("not to sample", mocklog.debug.call_args[0][0])
开发者ID:daf,项目名称:pyon,代码行数:11,代码来源:test_endpoint.py

示例11: test__sample_request_exception

    def test__sample_request_exception(self, mocklog):

        e = RPCResponseEndpointUnit(interceptors={})

        e._get_sflow_manager = Mock(return_value=Mock(spec=SFlowManager))
        e._get_sflow_manager.return_value.should_sample = True
        e._build_sample = Mock(side_effect=TestError)

        e._sample_request(sentinel.status, sentinel.status_descr, sentinel.msg, sentinel.headers, sentinel.response, sentinel.response_headers)

        mocklog.exception.assert_called_once_with("Could not sample, ignoring")
开发者ID:daf,项目名称:pyon,代码行数:11,代码来源:test_endpoint.py

示例12: test__message_received_interceptor_exception

    def test__message_received_interceptor_exception(self):
        e = RPCResponseEndpointUnit(routing_obj=self)
        e.send = Mock()
        e.send.return_value = sentinel.sent
        with patch('pyon.net.endpoint.ResponseEndpointUnit._message_received', new=Mock(side_effect=exception.IonException)):
            retval = e._message_received(sentinel.msg, {})

            self.assertEquals(retval, sentinel.sent)
            e.send.assert_called_once_with(None, {'status_code': -1,
                                                  'error_message':'',
                                                  'conv-id': '',
                                                  'conv-seq': 2,
                                                  'protocol':''})
开发者ID:blazetopher,项目名称:pyon,代码行数:13,代码来源:test_endpoint.py

示例13: test_endpoint_receive

    def test_endpoint_receive(self):
        self._ar = event.AsyncResult()

        # build a command object to be returned by the mocked channel
        class FakeMsg(object):
            def __init__(self):
                self.named = ["ein", "zwei"]
        cvalue = FakeMsg()

        e = RPCResponseEndpointUnit(routing_obj=self, interceptors={})
        ch = self._setup_mock_channel(value=cvalue, op="simple")
        e.attach_channel(ch)

        self._do_listen(e)
        args = self._ar.get(timeout=10)

        self.assertEquals(args, ["ein", "zwei"])
开发者ID:daf,项目名称:pyon,代码行数:17,代码来源:test_endpoint.py

示例14: _build_header

    def _build_header(self, raw_msg, raw_headers):
        """
        Override to direct the calls in _build_header - first the RPCResponse side, then the Process mixin.
        """
        header1 = RPCResponseEndpointUnit._build_header(self, raw_msg, raw_headers)
        header2 = ProcessEndpointUnitMixin._build_header(self, raw_msg, raw_headers)

        header1.update(header2)

        return header1
开发者ID:edwardhunter,项目名称:scioncc,代码行数:10,代码来源:endpoint.py

示例15: test__message_received_interceptor_exception

    def test__message_received_interceptor_exception(self):
        e = RPCResponseEndpointUnit(routing_obj=self)
        e.send = Mock()
        e.send.return_value = sentinel.sent
        with patch(
            "pyon.net.endpoint.ResponseEndpointUnit._message_received", new=Mock(side_effect=exception.IonException)
        ):
            retval = e._message_received(sentinel.msg, {})

            self.assertEquals(retval, sentinel.sent)
            e.send.assert_called_once_with(
                None,
                {
                    "status_code": -1,
                    "error_message": "",
                    "conv-id": "",
                    "conv-seq": 2,
                    "protocol": "",
                    "performative": "failure",
                },
            )
开发者ID:ooici-dm,项目名称:pyon,代码行数:21,代码来源:test_endpoint.py


注:本文中的pyon.net.endpoint.RPCResponseEndpointUnit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。