Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ngaya-ll committed Jun 10, 2020
1 parent 18a9c9d commit 91af7a8
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions tests/validator20/validate_definitions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,34 +134,17 @@ def test_type_array_without_items_succeed_fails():
assert str(excinfo.value) == 'Definition of type array must define `items` property (definition #/definitions/definition_1).'


def test_type_object_additional_properties_dict_succeeds():
def test_non_dict_fails_with_informative_error_message():
definitions = {
'Example': {
'type': 'object',
'additionalProperties': {
'type': 'string',
},
},
'Example': 'invalid',
}

validate_definitions(definitions, lambda x: x)


def test_type_object_additional_properties_boolean_fails():
# See https://github.com/OAI/OpenAPI-Specification/issues/668
definitions = {
'Example': {
'type': 'object',
'additionalProperties': False,
},
}

with pytest.raises(SwaggerValidationError) as exc_info:
with pytest.raises(
SwaggerValidationError,
match=r"Definition of #/definitions/Example must be a dict; got .*",
):
validate_definitions(definitions, lambda x: x)

assert str(exc_info.value) == "Definition of #/definitions/Example/additionalProperties " \
"must be a dict; got bool"


def test_inline_model_is_not_valid_validation_fails():
definitions = {
Expand Down

0 comments on commit 91af7a8

Please sign in to comment.