def test_invalid_file_extension(settings, yaml_app): """Fixture for setting up a Swagger 2.0 version of the test testapp.""" settings['pyramid_swagger.swagger_versions'] = ['2.0'] settings['pyramid_swagger.user_formats'] = [yaml_app] with pytest.raises(Exception): App(main({}, **settings))
def test_recursive_swagger_api_internal_refs(): recursive_test_app = App( main({}, **{ 'pyramid_swagger.schema_directory': 'tests/sample_schemas/recursive_app/internal/', })) recursive_test_app.get('/swagger.json', status=200)
def test_base_path_api_docs_on_good_app_schema(): base_path = '/web/base/path' recursive_test_app = App( main({}, **{ 'pyramid_swagger.schema_directory': 'tests/sample_schemas/good_app/', 'pyramid_swagger.base_path_api_docs': base_path })) recursive_test_app.get(base_path + '/swagger.json', status=200) recursive_test_app.get('/swagger.json', status=404)
def build_test_app(swagger_versions, **overrides): """Fixture for setting up a test test_app with particular settings.""" from tests.acceptance.app import main from webtest import TestApp as App settings = dict({ 'pyramid_swagger.schema_directory': 'tests/sample_schemas/good_app/', 'pyramid_swagger.enable_request_validation': True, 'pyramid_swagger.enable_response_validation': False, 'pyramid_swagger.enable_swagger_spec_validation': False, 'pyramid_swagger.swagger_versions': swagger_versions}, **overrides ) return App(main({}, **settings))
def build_test_app(swagger_versions, **overrides): """Fixture for setting up a test test_app with particular settings.""" from tests.acceptance.app import main from webtest import TestApp as App settings = dict( { 'pyramid_swagger.schema_directory': 'tests/sample_schemas/good_app/', 'pyramid_swagger.enable_request_validation': True, 'pyramid_swagger.enable_response_validation': False, 'pyramid_swagger.enable_swagger_spec_validation': False, 'pyramid_swagger.swagger_versions': swagger_versions }, **overrides) return App(main({}, **settings))
def test_base_path_api_docs_with_script_name_on_recursive_app_schema(): base_path = '/some/path' script_name = '/scriptname' test_app = App( main({}, **{ 'pyramid_swagger.schema_directory': 'tests/sample_schemas/recursive_app/external/', 'pyramid_swagger.base_path_api_docs': base_path }), {'SCRIPT_NAME': script_name}) test_app.get(script_name + base_path + '/swagger.json', status=200) test_app.get('/swagger.json', status=404) test_app.get(script_name + base_path + '/external.json', status=200) test_app.get('/external.json', status=404)
def ini_app(): settings = get_appsettings(os.path.join(os.path.dirname(__file__), 'app', 'config.ini'), name='main') return App(main({}, **settings))
def test_app_deref(settings): """Fixture for setting up a Swagger 2.0 version of the test test_app test app serves swagger schemas with refs dereferenced.""" settings['pyramid_swagger.dereference_served_schema'] = True return App(main({}, **settings))
def swagger_12_and_20_test_app(settings): """Fixture for setting up a Swagger 1.2 and Swagger 2.0 version of the test test_app. """ settings['pyramid_swagger.swagger_versions'] = ['1.2', '2.0'] return App(main({}, **settings))
def test_app_with_prefer_conf(settings): """Fixture for setting up a Swagger 2.0 version with a particular route `standard` added to `prefer_20_routes` option.""" settings['pyramid_swagger.prefer_20_routes'] = ['standard'] return App(main({}, **settings))
def test_app_deref(settings): """Fixture for setting up a Swagger 2.0 version of the test test_app test app serves swagger schemas with refs dereferenced.""" settings['pyramid_swagger.dereference_served_schema'] = True return App(main({}, **settings))
def test_app(settings): """Fixture for setting up a Swagger 2.0 version of the test test_app.""" return App(main({}, **settings))
def test_app(settings): """Fixture for setting up a Swagger 2.0 version of the test test_app.""" return App(main({}, **settings))
def ini_app(): settings = get_appsettings(os.path.join(os.path.dirname(__file__), 'app', 'config.ini'), name='main') return App(main({}, **settings))
def test_app_with_no_prefer_conf(settings): """Fixture for setting up a Swagger 2.0 version with no `prefer_20_routes` option added to settings.""" return App(main({}, **settings))
def test_app_with_prefer_conf(settings): """Fixture for setting up a Swagger 2.0 version with a particular route `standard` added to `prefer_20_routes` option.""" settings['pyramid_swagger.prefer_20_routes'] = ['standard'] return App(main({}, **settings))
def test_virtual_subpath(settings): test_app = App(main({}, **settings), {'SCRIPT_NAME': '/subpath'}) test_app.get('/subpath/swagger.json', status=200)
def testapp_with_base64(settings, user_format): """Fixture for setting up a Swagger 2.0 version of the test testapp.""" settings['pyramid_swagger.swagger_versions'] = ['2.0'] settings['pyramid_swagger.user_formats'] = [user_format] return App(main({}, **settings))
def default_test_app(settings): return App(main({}, **settings))
def testapp_with_base64(settings, user_format): """Fixture for setting up a Swagger 2.0 version of the test testapp.""" settings['pyramid_swagger.swagger_versions'] = ['2.0'] settings['pyramid_swagger.user_formats'] = [user_format] return App(main({}, **settings))
def test_app_with_no_prefer_conf(settings): """Fixture for setting up a Swagger 2.0 version with no `prefer_20_routes` option added to settings.""" return App(main({}, **settings))