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)
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)
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)
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)
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)
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)