Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_unknown_response_code(args):
app, kwargs = args
# When endpoint returns a status code, that is not listed in "responses"
# And "status_code_conformance" is specified
results = execute(**kwargs, checks=(status_code_conformance,), hypothesis_options={"max_examples": 1})
# Then there should be a failure
assert results.has_failures
check = results.results[0].checks[0]
assert check.name == "status_code_conformance"
assert check.value == Status.failure
def test_status_code_conformance_invalid(value, swagger_20):
response = make_response()
response.status_code = value
case = make_case(swagger_20, {"responses": {"5XX"}})
with pytest.raises(AssertionError):
status_code_conformance(response, case)
def test_status_code_conformance_valid(value, swagger_20):
response = make_response()
response.status_code = value
case = make_case(swagger_20, {"responses": {"4XX"}})
status_code_conformance(response, case)