add test to check parameter uniqueness is handled correctly in validator

This commit is contained in:
Gerhard Weis 2019-06-20 06:38:00 +10:00
parent d490d5774b
commit 3d23f17c1d

View file

@ -306,8 +306,7 @@ class TestPathItemParamsValidator(object):
assert result.parameters == {'query': {'resId': 10}}
def test_request_override_param(self, spec_dict):
# override parameter path parameter on operation
# (name and in property must match)
# override path parameter on operation
spec_dict["paths"]["/resource"]["get"]["parameters"] = [
{
# full valid parameter object required
@ -327,6 +326,29 @@ class TestPathItemParamsValidator(object):
assert result.body is None
assert result.parameters == {}
def test_request_override_param_uniqueness(self, spec_dict):
# add parameter on operation with same name as on path but
# different location
spec_dict["paths"]["/resource"]["get"]["parameters"] = [
{
# full valid parameter object required
"name": "resId",
"in": "header",
"required": False,
"schema": {
"type": "integer",
},
}
]
validator = RequestValidator(create_spec(spec_dict))
request = MockRequest('http://example.com', 'get', '/resource')
result = validator.validate(request)
assert len(result.errors) == 1
assert type(result.errors[0]) == MissingRequiredParameter
assert result.body is None
assert result.parameters == {}
class TestResponseValidator(object):