예제 #1
0
    def test_marshal_with_error(self):
        error = 'error message'
        expected = {
            'error': 'error message',
            'value': None
        }

        response = CommandResponse(error=error)
        result = response.marshal()
        self.assertEquals(result, expected)
예제 #2
0
파일: server.py 프로젝트: jaunis/xivo-bus
    def _process_next_command(self, request):
        response = CommandResponse()
        try:
            command = self._marshaler.unmarshal_command(request)
            callback = self._commands_callback[command.name]
            response.value = self._call_callback(callback, command)
        except BusCtlServerError as e:
            response.error = e.error
        except Exception:
            logger.error('Error while processing command', exc_info=True)
            response.error = error.SERVER_ERROR

        return self._reply_response(response)
예제 #3
0
파일: server.py 프로젝트: jaunis/xivo-bus
    def _process_next_command(self, request):
        response = CommandResponse()
        try:
            command = self._marshaler.unmarshal_command(request)
            callback = self._commands_callback[command.name]
            response.value = self._call_callback(callback, command)
        except BusCtlServerError as e:
            response.error = e.error
        except Exception:
            logger.error('Error while processing command', exc_info=True)
            response.error = error.SERVER_ERROR

        return self._reply_response(response)
예제 #4
0
    def test_unmarshal_with_error_message(self):
        msg = {
            'error': 'error message',
            'value': None
        }

        response = CommandResponse.unmarshal(msg)

        self.assertEquals(response.value, None)
        self.assertEquals(response.error, 'error message')
예제 #5
0
    def test_marshal_with_value(self):
        value = {
            'agent_number': '1000',
            'extension': '2000',
            'context': 'default'
        }
        expected = {
            'error': None,
            'value': {
                'agent_number': '1000',
                'extension': '2000',
                'context': 'default'
            }
        }

        response = CommandResponse(value=value)
        result = response.marshal()

        self.assertEquals(result, expected)
예제 #6
0
    def test_unmarshal_with_value_message(self):
        msg = {
            'error': None,
            'value': {
                'agent_number': '1000',
                'extension': '2000',
                'context': 'default'
            }
        }

        response = CommandResponse.unmarshal(msg)

        self.assertEquals(response.value, msg['value'])
        self.assertEquals(response.error, None)
예제 #7
0
 def unmarshal_response(self, data):
     msg = self.unmarshal_message(data)
     return CommandResponse.unmarshal(msg)
예제 #8
0
 def unmarshal_response(self, data):
     msg = self.unmarshal_message(data)
     return CommandResponse.unmarshal(msg)