Beispiel #1
0
def args(request, variant, is_compiled):
    schema, instance = request.node.get_closest_marker("data").args
    if variant == "jsonschema-rs-is-valid":
        if is_compiled:
            return jsonschema_rs.JSONSchema(
                schema, with_meta_schemas=True).is_valid, instance
        else:
            return partial(jsonschema_rs.is_valid,
                           with_meta_schemas=True), schema, instance
    if variant == "jsonschema-rs-validate":
        if is_compiled:
            return jsonschema_rs.JSONSchema(
                schema, with_meta_schemas=True).validate, instance
        else:
            return partial(jsonschema_rs.validate,
                           with_meta_schemas=True), schema, instance
    if variant == "jsonschema":
        if is_compiled:
            return jsonschema.validators.validator_for(schema)(
                schema).is_valid, instance
        else:
            return jsonschema.validate, instance, schema
    if variant == "fastjsonschema":
        if is_compiled:
            return fastjsonschema.compile(schema, use_default=False), instance
        else:
            return partial(fastjsonschema.validate,
                           use_default=False), schema, instance
Beispiel #2
0
 def validate_request(self, request: typing.Any):
     schema = self._get_request_schema(request)
     for k, s in schema.items():
         if not s:
             continue
         jsonschema_rs.JSONSchema(s).validate(
             self._get_request_data(request, k))
Beispiel #3
0
def args(request, is_compiled):
    schema, instance = request.node.get_closest_marker("data").args
    if request.param == "rust":
        if is_compiled:
            return jsonschema_rs.JSONSchema(schema).is_valid, instance
        else:
            return jsonschema_rs.is_valid, schema, instance
    if request.param == "python":
        if is_compiled:
            return jsonschema.validators.validator_for(schema)(
                schema).is_valid, instance
        else:
            return jsonschema.validate, instance, schema
    if request.param == "python-fast":
        if is_compiled:
            return fastjsonschema.compile(schema), instance
        else:
            return fastjsonschema.validate, schema, instance