コード例 #1
0
def test_unexpected_attribute():
    data = {"id": "foo", "abc": "xyz"}

    schema = Schema("id", [Attribute("id", Datatype.String, Cardinality.One)])

    with pytest.raises(UnknownAttribute):
        validate(data, schema)
コード例 #2
0
def test_representation_error_bool():
    data = {"id": "foo", "abc": True}

    schema = Schema("id", [
        Attribute("id", Datatype.String, Cardinality.One),
        Attribute("abc", Datatype.Integer, Cardinality.One)
    ])

    with pytest.raises(RepresentationError):
        validate(data, schema)
コード例 #3
0
def test_cardinality_1_mismatch():
    data = {"id": "foo", "abc": ["xyz"]}

    schema = Schema("id", [
        Attribute("id", Datatype.String, Cardinality.One),
        Attribute("abc", Datatype.String, Cardinality.One)
    ])

    with pytest.raises(CardinalityMismatch):
        validate(data, schema)
コード例 #4
0
def test_missing_pk():
    data = {"abc": "xyz"}

    schema = Schema("id", [
        Attribute("id", Datatype.String, Cardinality.One),
        Attribute("abc", Datatype.String, Cardinality.One)
    ])

    with pytest.raises(MissingPrimaryKey):
        validate(data, schema)
コード例 #5
0
def test_valid_n_string():
    data = {"id": "foo", "abc": ["xyz"]}

    schema = Schema("id", [
        Attribute("id", Datatype.String, Cardinality.One),
        Attribute("abc", Datatype.String, Cardinality.Many)
    ])

    assert validate(data, schema)
コード例 #6
0
def test_nully():
    data = {"id": "foo", "abc": None}

    schema = Schema("id", [
        Attribute("id", Datatype.String, Cardinality.One),
        Attribute("abc", Datatype.Integer, Cardinality.One)
    ])

    assert validate(data, schema)