def __call__(self, **op_kwargs): """Invoke the actual HTTP request and return a future. :rtype: :class:`bravado.http_future.HTTPFuture` """ log.debug(u"%s(%s)" % (self.operation.operation_id, op_kwargs)) warn_for_deprecated_op(self.operation) # Apply request_options defaults request_options = dict(REQUEST_OPTIONS_DEFAULTS, **(op_kwargs.pop('_request_options', {}))) request_params = construct_request(self.operation, request_options, **op_kwargs) config = self.operation.swagger_spec.config http_client = self.operation.swagger_spec.http_client # Per-request config overrides client wide config also_return_response = request_options.get( 'also_return_response', config['also_return_response']) return http_client.request( request_params, operation=self.operation, response_callbacks=request_options['response_callbacks'], also_return_response=also_return_response)
def __call__(self, **op_kwargs): """Invoke the actual HTTP request and return a future. :rtype: :class:`bravado.http_future.HTTPFuture` """ log.debug(u"%s(%s)" % (self.operation.operation_id, op_kwargs)) warn_for_deprecated_op(self.operation) # Apply request_options defaults request_options = dict( REQUEST_OPTIONS_DEFAULTS, **(op_kwargs.pop('_request_options', {}))) request_params = construct_request( self.operation, request_options, **op_kwargs) config = self.operation.swagger_spec.config http_client = self.operation.swagger_spec.http_client # Per-request config overrides client wide config also_return_response = request_options.get( 'also_return_response', config['also_return_response']) return http_client.request( request_params, operation=self.operation, response_callbacks=request_options['response_callbacks'], also_return_response=also_return_response)
def test_warn(mock_warn): op_spec = {'deprecated': True, 'x-deprecated-date': 'foo', 'x-removal-date': 'bar'} op = Mock(spec=CallableOperation, operation_id='bla', op_spec=op_spec) warn_for_deprecated_op(op) mock_warn.assert_called_once_with( '[DEPRECATED] bla has now been deprecated.' ' Deprecation Date: foo. Removal Date: bar', Warning)
def test_warn(mock_warn): op_spec = { 'deprecated': True, 'x-deprecated-date': 'foo', 'x-removal-date': 'bar' } op = Mock(spec=CallableOperation, operation_id='bla', op_spec=op_spec) warn_for_deprecated_op(op) mock_warn.assert_called_once_with( '[DEPRECATED] bla has now been deprecated.' ' Deprecation Date: foo. Removal Date: bar', Warning)
def __call__(self, **op_kwargs): """ Invoke the actual HTTP request and return a future that encapsulates the HTTP response. :rtype: :class:`bravado.http_future.HTTPFuture` """ log.debug(u"%s(%s)" % (self.operation.operation_id, op_kwargs)) warn_for_deprecated_op(self.operation) request_params = self.construct_request(**op_kwargs) callback = functools.partial(response_callback, operation=self) return self.operation.swagger_spec.http_client.request( request_params, callback)
def __call__(self, **op_kwargs): """ Invoke the actual HTTP request and return a future that encapsulates the HTTP response. :rtype: :class:`bravado.http_future.HTTPFuture` """ log.debug(u"%s(%s)" % (self.operation.operation_id, op_kwargs)) warn_for_deprecated_op(self.operation) request_params = self.construct_request(**op_kwargs) callback = functools.partial(response_callback, operation=self) return self.operation.swagger_spec.http_client.request(request_params, callback)
def __call__(self, **op_kwargs): """Invoke the actual HTTP request and return a future. :rtype: :class:`bravado.http_future.HTTPFuture` """ log.debug(u'%s(%s)', self.operation.operation_id, op_kwargs) warn_for_deprecated_op(self.operation) # Get per-request config request_options = op_kwargs.pop('_request_options', {}) request_config = RequestConfig(request_options, self.also_return_response) request_params = construct_request( self.operation, request_options, **op_kwargs) http_client = self.operation.swagger_spec.http_client return http_client.request( request_params, operation=self.operation, request_config=request_config, )
def test_no_warn_if_deprecate_flag_not_present(mock_warn): op = Mock(spec=CallableOperation, operation_id='bla', op_spec={}) warn_for_deprecated_op(op) assert not mock_warn.called
def test_no_warn_if_false(mock_warn): op_spec = {'deprecated': False} op = Mock(spec=CallableOperation, operation_id='bla', op_spec=op_spec) warn_for_deprecated_op(op) assert not mock_warn.called
def test_no_warn_if_deprecate_flag_not_present(mock_warn): op = Mock(spec=CallableOperation, operation_id='bla', op_spec={}) warn_for_deprecated_op(op) assert not mock_warn.called
def test_no_warn_if_false(mock_warn): op_spec = {'deprecated': False} op = Mock(spec=CallableOperation, operation_id='bla', op_spec=op_spec) warn_for_deprecated_op(op) assert not mock_warn.called