-
Notifications
You must be signed in to change notification settings - Fork 46
/
recursive_app_test.py
50 lines (37 loc) · 1.33 KB
/
recursive_app_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import json
import pytest
import yaml
from six import BytesIO
from webtest import TestApp as App
from tests.acceptance.app import main
DESERIALIZERS = {
'json': lambda r: json.loads(r.body.decode('utf-8')),
'yaml': lambda r: yaml.safe_load(BytesIO(r.body)),
}
@pytest.fixture
def settings():
dir_path = 'tests/sample_schemas/recursive_app/external/'
return {
'pyramid_swagger.schema_directory': dir_path,
'pyramid_swagger.enable_request_validation': True,
'pyramid_swagger.enable_swagger_spec_validation': True,
'pyramid_swagger.swagger_versions': ['2.0']
}
@pytest.fixture
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))
@pytest.mark.parametrize('schema_format', ['json'])
def test_dereferenced_swagger_schema_bravado_client(
schema_format,
test_app_deref,
):
from bravado.client import SwaggerClient
response = test_app_deref.get('/swagger.{0}'.format(schema_format))
deserializer = DESERIALIZERS[schema_format]
specs = deserializer(response)
SwaggerClient.from_spec(specs)