+2
-2
@@ -45,8 +45,8 @@ def validate_schema():
|
||||
from flex.core import parse as validate_flex
|
||||
from swagger_spec_validator.validator20 import validate_spec as validate_ssv
|
||||
|
||||
validate_flex(swagger)
|
||||
validate_ssv(swagger)
|
||||
validate_flex(copy.deepcopy(swagger))
|
||||
validate_ssv(copy.deepcopy(swagger))
|
||||
|
||||
return validate_schema
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
from collections import OrderedDict
|
||||
|
||||
import pytest
|
||||
from ruamel import yaml
|
||||
@@ -46,6 +47,26 @@ def test_redoc(client, validate_schema):
|
||||
_validate_text_schema_view(client, validate_schema, '/redoc/?format=openapi', json.loads)
|
||||
|
||||
|
||||
def test_caching(client, validate_schema):
|
||||
prev_schema = None
|
||||
|
||||
for i in range(3):
|
||||
_validate_ui_schema_view(client, '/cached/redoc/', 'redoc/redoc.min.js')
|
||||
_validate_text_schema_view(client, validate_schema, '/cached/redoc/?format=openapi', json.loads)
|
||||
_validate_ui_schema_view(client, '/cached/swagger/', 'swagger-ui-dist/swagger-ui-bundle.js')
|
||||
_validate_text_schema_view(client, validate_schema, '/cached/swagger/?format=openapi', json.loads)
|
||||
|
||||
json_schema = client.get('/cached/swagger.json')
|
||||
assert json_schema.status_code == 200
|
||||
json_schema = json.loads(json_schema.content.decode('utf-8'), object_pairs_hook=OrderedDict)
|
||||
if prev_schema is None:
|
||||
validate_schema(json_schema)
|
||||
prev_schema = json_schema
|
||||
else:
|
||||
from datadiff.tools import assert_equal
|
||||
assert_equal(prev_schema, json_schema)
|
||||
|
||||
|
||||
@pytest.mark.urls('urlconfs.non_public_urls')
|
||||
def test_non_public(client):
|
||||
response = client.get('/private/swagger.yaml')
|
||||
|
||||
Reference in New Issue
Block a user