Skip to content

Commit

Permalink
add failing test for pipermerriam#138
Browse files Browse the repository at this point in the history
  • Loading branch information
danopz committed Feb 22, 2018
1 parent cf87e40 commit c13657d
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/validation/request/test_request_body_parameter_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,53 @@ def test_request_body_parameter_validation_with_invalid_value(user_post_schema):
MESSAGES['format']['invalid_email'],
err.value.detail,
)


def test_request_body_parameter_validation_invalid_without_ref():
"""
Test validating the request body with a invalid post.
"""
schema = SchemaFactory(
paths={
'/post/': {
'post': {
'consumes': ['application/json'],
'parameters': [
{
'in': 'body',
'name': 'body',
'required': True,
'schema': {
'type': 'object',
'required': ['name'],
'properties': {
'name': {
'type': 'string'
}
}
}
}
],
'responses': {200: {'description': "Success"}},
}
}
}
)

request = RequestFactory(
url='http://www.example.com/post/',
content_type='application/json',
body=json.dumps({}),
method=POST,
)

with pytest.raises(ValidationError) as err:
validate_request(
request=request,
schema=schema,
)

assert_message_in_errors(
MESSAGES['required']['required'],
err.value.detail,
)

0 comments on commit c13657d

Please sign in to comment.