

def test_id_or_uuid():
    id_field = UnionType((IntType, UUIDType))
    result = id_field.convert('ee5a16cb-0ee1-46bc-ac40-fb3018b1d29b')
    assert (result == uuid.UUID('ee5a16cb-0ee1-46bc-ac40-fb3018b1d29b'))
    assert (type(id_field.to_primitive(result)) is str)
    result = id_field.convert('99999')
    assert (result == 99999)
    assert (type(result) is int)
    assert (type(id_field.to_primitive(result)) is int)

dataset/ETHPy150Open schematics/schematics/tests/test_union_type.py test_id_or_uuid/original