mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-07 12:27:46 +00:00
- App and Api options must be provided through the "options" argument (``old_style_options`` have been removed). - You must specify a form content-type in 'consumes' in order to consume form data. - The `Operation` interface has been formalized in the `AbstractOperation` class. - The `Operation` class has been renamed to `Swagger2Operation`. - Array parameter deserialization now follows the Swagger 2.0 spec more closely. In situations when a query parameter is passed multiple times, and the collectionFormat is either csv or pipes, the right-most value will be used. For example, `?q=1,2,3&q=4,5,6` will result in `q = [4, 5, 6]`. The old behavior is available by setting the collectionFormat to `multi`, or by importing `decorators.uri_parsing.AlwaysMultiURIParser` and passing `parser_class=AlwaysMultiURIParser` to your Api. - The spec validator library has changed from `swagger-spec-validator` to `openapi-spec-validator`. - Errors that previously raised `SwaggerValidationError` now raise the `InvalidSpecification` exception. All spec validation errors should be wrapped with `InvalidSpecification`. - Support for nullable/x-nullable, readOnly and writeOnly/x-writeOnly has been added to the standard json schema validator. - Custom validators can now be specified on api level (instead of app level). - Added support for basic authentication and apikey authentication - If unsupported security requirements are defined or ``x-tokenInfoFunc``/``x-tokenInfoUrl`` is missing, connexion now denies requests instead of allowing access without security-check. - Accessing ``connexion.request.user`` / ``flask.request.user`` is no longer supported, use ``connexion.context['user']`` instead
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
import math
|
|
|
|
import connexion.apps
|
|
import pytest
|
|
from connexion import utils
|
|
from mock import MagicMock
|
|
|
|
|
|
def test_get_function_from_name():
|
|
function = utils.get_function_from_name('math.ceil')
|
|
assert function == math.ceil
|
|
assert function(2.7) == 3
|
|
|
|
|
|
def test_get_function_from_name_no_module():
|
|
with pytest.raises(ValueError):
|
|
utils.get_function_from_name('math')
|
|
|
|
|
|
def test_get_function_from_name_attr_error(monkeypatch):
|
|
"""
|
|
Test attribute error without import error on get_function_from_name.
|
|
Attribute errors due to import errors are tested on
|
|
test_api.test_invalid_operation_does_stop_application_to_setup
|
|
"""
|
|
deep_attr_mock = MagicMock()
|
|
deep_attr_mock.side_effect = AttributeError
|
|
monkeypatch.setattr("connexion.utils.deep_getattr", deep_attr_mock)
|
|
with pytest.raises(AttributeError):
|
|
utils.get_function_from_name('math.ceil')
|
|
|
|
|
|
def test_get_function_from_name_for_class_method():
|
|
function = utils.get_function_from_name('connexion.FlaskApp.common_error_handler')
|
|
assert function == connexion.FlaskApp.common_error_handler
|
|
|
|
|
|
def test_boolean():
|
|
assert utils.boolean('true')
|
|
assert utils.boolean('True')
|
|
assert utils.boolean('TRUE')
|
|
assert utils.boolean(True)
|
|
assert not utils.boolean('false')
|
|
assert not utils.boolean('False')
|
|
assert not utils.boolean('FALSE')
|
|
assert not utils.boolean(False)
|
|
|
|
with pytest.raises(ValueError):
|
|
utils.boolean('foo')
|
|
|
|
with pytest.raises(ValueError):
|
|
utils.boolean(None)
|