Pass along exceptions related to user mistakes

This commit is contained in:
Rafael Caricio
2016-09-13 12:00:41 +02:00
parent 3f33a54ec3
commit ccce2f85fe
4 changed files with 32 additions and 0 deletions

View File

@@ -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

View 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!')

View 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

View File

@@ -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):