How to use the schemathesis.checks.status_code_conformance function in schemathesis

To help you get started, we’ve selected a few schemathesis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kiwicom / schemathesis / test / runner / test_runner.py View on Github external
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
github kiwicom / schemathesis / test / runner / test_checks.py View on Github external
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)
github kiwicom / schemathesis / test / runner / test_checks.py View on Github external
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)