How to use the schemathesis.from_dict 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 / test_parametrizer.py View on Github external
def test_is_schemathesis_test():
    # When a test is wrapped into with `parametrize`
    schema = schemathesis.from_dict(MINIMAL_SCHEMA)

    @schema.parametrize()
    def test_a():
        pass

    # Then is should be recognized as a schemathesis test
    assert is_schemathesis_test(test_a)
github kiwicom / schemathesis / test / test_schemas.py View on Github external
"paths": {
            "teapot": {
                "post": {
                    "parameters": [
                        {
                            "schema": {"$ref": "test/data/petstore_v2.yaml#/definitions/User"},
                            "in": "body",
                            "name": "user",
                            "required": True,
                        }
                    ]
                }
            }
        },
    }
    schema = schemathesis.from_dict(raw_schema)
    assert schema["/api/teapot"]["post"].body == {
        "type": "object",
        "properties": {
            "id": {"type": "integer", "format": "int64"},
            "username": {"type": "string"},
            "firstName": {"type": "string"},
            "lastName": {"type": "string"},
            "email": {"type": "string"},
            "password": {"type": "string"},
            "phone": {"type": "string"},
            "userStatus": {"type": "integer", "format": "int32", "description": "User Status"},
        },
        "xml": {"name": "User"},
    }
github kiwicom / schemathesis / test / utils.py View on Github external
def get_schema(schema_name: str = "simple_swagger.yaml", **kwargs: Any) -> BaseSchema:
    schema = make_schema(schema_name, **kwargs)
    return schemathesis.from_dict(schema)
github kiwicom / schemathesis / test / test_wsgi.py View on Github external
def test_cookies(flask_app):
    @flask_app.route("/cookies", methods=["GET"])
    def cookies():
        return jsonify(request.cookies)

    schema = schemathesis.from_dict(
        {
            "openapi": "3.0.2",
            "info": {"title": "Test", "description": "Test", "version": "0.1.0"},
            "paths": {
                "/cookies": {
                    "get": {
                        "parameters": [
                            {
                                "name": "token",
                                "in": "cookie",
                                "required": True,
                                "schema": {"type": "string", "const": "test"},
                            }
                        ]
                    }
                }
github kiwicom / schemathesis / test / test_loaders.py View on Github external
def test_unsupported_type():
    with pytest.raises(ValueError, match="^Unsupported schema type$"):
        schemathesis.from_dict({})
github kiwicom / schemathesis / test / schemas / utils.py View on Github external
def get_schema(schema_name="simple_swagger.yaml", **kwargs):
    schema = make_schema(schema_name, **kwargs)
    return schemathesis.from_dict(schema)