mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-10 12:27:46 +00:00
Pass along exceptions related to user mistakes
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
# This is a test file, please do not delete.
|
||||
# It is used by the test:
|
||||
# - `test_operation.py:test_invalid_operation_does_stop_application_to_setup`
|
||||
# - `test_api.py:test_invalid_operation_does_stop_application_to_setup`
|
||||
# - `test_api.py:test_invalid_operation_does_not_stop_application_in_debug_mode`
|
||||
from foo.bar import foobar # noqa
|
||||
|
||||
6
tests/fakeapi/module_with_exception.py
Normal file
6
tests/fakeapi/module_with_exception.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# This is a test file, please do not delete.
|
||||
# It is used by the test:
|
||||
# - `test_operation.py:test_invalid_operation_does_stop_application_to_setup`
|
||||
# - `test_api.py:test_invalid_operation_does_stop_application_to_setup`
|
||||
# - `test_api.py:test_invalid_operation_does_not_stop_application_in_debug_mode`
|
||||
raise ValueError('Forced exception!')
|
||||
17
tests/fixtures/user_module_loading_error/swagger.yaml
vendored
Normal file
17
tests/fixtures/user_module_loading_error/swagger.yaml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
swagger: "2.0"
|
||||
|
||||
info:
|
||||
title: "{{title}}"
|
||||
version: "1.0"
|
||||
|
||||
basePath: /v1.1
|
||||
|
||||
paths:
|
||||
/welcome:
|
||||
get:
|
||||
operationId: fakeapi.module_with_exception.something
|
||||
responses:
|
||||
200:
|
||||
description: greeting response
|
||||
schema:
|
||||
type: object
|
||||
@@ -39,6 +39,9 @@ def test_invalid_operation_does_stop_application_to_setup():
|
||||
with pytest.raises(ResolverError):
|
||||
Api(TEST_FOLDER / "fixtures/missing_op_id/swagger.yaml", "/api/v1.0",
|
||||
{'title': 'OK'})
|
||||
with pytest.raises(ValueError):
|
||||
Api(TEST_FOLDER / "fixtures/user_module_loading_error/swagger.yaml", "/api/v1.0",
|
||||
{'title': 'OK'})
|
||||
|
||||
|
||||
def test_invalid_operation_does_not_stop_application_in_debug_mode():
|
||||
@@ -50,6 +53,10 @@ def test_invalid_operation_does_not_stop_application_in_debug_mode():
|
||||
{'title': 'OK'}, debug=True)
|
||||
assert api.specification['info']['title'] == 'OK'
|
||||
|
||||
api = Api(TEST_FOLDER / "fixtures/user_module_loading_error/swagger.yaml", "/api/v1.0",
|
||||
{'title': 'OK'}, debug=True)
|
||||
assert api.specification['info']['title'] == 'OK'
|
||||
|
||||
|
||||
def test_invalid_schema_file_structure():
|
||||
with pytest.raises(SwaggerValidationError):
|
||||
|
||||
Reference in New Issue
Block a user