Exemple #1
0
    def test__message_received_error_in_op(self):
        # we want to make sure IonExceptions raised in business logic get a response, now that
        # _message_received sends the responses

        class FakeMsg(object):
            pass

        cvalue = FakeMsg()

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

        e.send = Mock()

        self._do_listen(e)

        assert_called_once_with_header(
            self, e.send, {
                'status_code': 401,
                'error_message': str(sentinel.unauth),
                'conv-id': sentinel.conv_id,
                'msg-rcvd': ANY,
                'conv-seq': 2,
                'protocol': '',
                'performative': 'failure'
            })
Exemple #2
0
    def test__message_received_error_in_op(self):
        # we want to make sure IonExceptions raised in business logic get a response, now that
        # _message_received sends the responses

        class FakeMsg(object):
            pass

        cvalue = FakeMsg()

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

        e.send = Mock()

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

        e.send.assert_called_once_with(
            None,
            {
                "status_code": 401,
                "error_message": str(sentinel.unauth),
                "conv-id": "",
                "conv-seq": 2,
                "protocol": "",
                "performative": "failure",
            },
        )
Exemple #3
0
    def test__message_received_error_in_op(self):
        # we want to make sure IonExceptions raised in business logic get a response, now that
        # _message_received sends the responses

        class FakeMsg(object):
            pass

        cvalue = FakeMsg()

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

        e.send = Mock()

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

        e.send.assert_called_once_with(
            None, {
                'status_code': 401,
                'error_message': str(sentinel.unauth),
                'conv-id': '',
                'conv-seq': 2,
                'protocol': '',
                'performative': 'failure'
            })
Exemple #4
0
    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':''})
Exemple #5
0
    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'})
Exemple #6
0
    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",
                },
            )
Exemple #7
0
    def test__message_received_error_in_op(self):
        # we want to make sure IonExceptions raised in business logic get a response, now that
        # _message_received sends the responses

        class FakeMsg(object):
            pass
        cvalue = FakeMsg()

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

        e.send = Mock()

        self._do_listen(e)

        assert_called_once_with_header(self, e.send, {'status_code': 401,
                                                      'error_message': str(sentinel.unauth),
                                                      'conv-id': sentinel.conv_id,
                                                      'conv-seq': 2,
                                                      'protocol':'',
                                                      'performative':'failure'})