Beispiel #1
0
def test_support_nullable_properties_not_iterable():
    schema = {
        "type": "object",
        "properties": {
            "foo": {
                "type": "string",
                "x-nullable": True
            }
        },
    }
    with pytest.raises(ValidationError):
        Draft4RequestValidator(schema).validate(12345)
Beispiel #2
0
def test_writeonly_required_error():
    schema = {
        "type": "object",
        "required": ["foo"],
        "properties": {
            "foo": {
                "type": "string",
                "writeOnly": True
            }
        },
    }
    with pytest.raises(ValidationError):
        Draft4RequestValidator(schema).validate({"bar": "baz"})
Beispiel #3
0
def test_support_nullable_properties_raises_validation_error():
    schema = {
        "type": "object",
        "properties": {
            "foo": {
                "type": "string",
                "x-nullable": False
            }
        },
    }

    with pytest.raises(ValidationError):
        Draft4RequestValidator(schema).validate({"foo": None})
Beispiel #4
0
def test_writeonly_value():
    schema = {
        "type": "object",
        "properties": {
            "foo": {
                "type": "string",
                "writeOnly": True
            }
        },
    }
    try:
        Draft4RequestValidator(schema).validate({"foo": "bar"})
    except ValidationError:
        pytest.fail("Shouldn't raise ValidationError")
Beispiel #5
0
def test_support_nullable_properties():
    schema = {
        "type": "object",
        "properties": {
            "foo": {
                "type": "string",
                "x-nullable": True
            }
        },
    }
    try:
        Draft4RequestValidator(schema).validate({"foo": None})
    except ValidationError:
        pytest.fail("Shouldn't raise ValidationError")
Beispiel #6
0
def test_nullable_enum_error():
    schema = {"enum": ["foo", 7]}
    with pytest.raises(ValidationError):
        Draft4RequestValidator(schema).validate(None)
Beispiel #7
0
def test_nullable_enum():
    schema = {"enum": ["foo", 7], "nullable": True}
    try:
        Draft4RequestValidator(schema).validate(None)
    except ValidationError:
        pytest.fail("Shouldn't raise ValidationError")