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_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)
"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"},
}
def get_schema(schema_name: str = "simple_swagger.yaml", **kwargs: Any) -> BaseSchema:
schema = make_schema(schema_name, **kwargs)
return schemathesis.from_dict(schema)
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"},
}
]
}
}
def test_unsupported_type():
with pytest.raises(ValueError, match="^Unsupported schema type$"):
schemathesis.from_dict({})
def get_schema(schema_name="simple_swagger.yaml", **kwargs):
schema = make_schema(schema_name, **kwargs)
return schemathesis.from_dict(schema)