コード例 #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)
コード例 #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"})
コード例 #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})
コード例 #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")
コード例 #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")
コード例 #6
0
def test_nullable_enum_error():
    schema = {"enum": ["foo", 7]}
    with pytest.raises(ValidationError):
        Draft4RequestValidator(schema).validate(None)
コード例 #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")