How to use the schemathesis.checks.content_type_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_known_content_type(args):
    app, kwargs = args
    # When endpoint returns a response with a proper content type
    # And "content_type_conformance" is specified
    results = execute(**kwargs, checks=(content_type_conformance,), hypothesis_options={"max_examples": 1})
    # Then there should be no a failures
    assert not results.has_failures
github kiwicom / schemathesis / test / runner / test_checks.py View on Github external
def test_content_type_conformance_valid(response, case):
    assert content_type_conformance(response, case) is None
github kiwicom / schemathesis / test / runner / test_checks.py View on Github external
def test_content_type_conformance_invalid(response, case):
    message = (
        f"^Received a response with '{response.headers['Content-Type']}' Content-Type, "
        "but it is not declared in the schema.\n\nDefined content types: application/json$"
    )
    with pytest.raises(AssertionError, match=message):
        content_type_conformance(response, case)