forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_types.py
More file actions
35 lines (25 loc) · 1.24 KB
/
test_types.py
File metadata and controls
35 lines (25 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
from feast.protos.feast.types.Value_pb2 import ValueType as ValueTypeProto
from feast.types import Array, Float32, String, from_value_type
def test_primitive_feast_type():
assert String.to_value_type() == ValueTypeProto.Enum.Value("STRING")
assert from_value_type(String.to_value_type()) == String
assert Float32.to_value_type() == ValueTypeProto.Enum.Value("FLOAT")
assert from_value_type(Float32.to_value_type()) == Float32
def test_array_feast_type():
array_float_32 = Array(Float32)
assert array_float_32.to_value_type() == ValueTypeProto.Enum.Value("FLOAT_LIST")
assert from_value_type(array_float_32.to_value_type()) == array_float_32
array_string = Array(String)
assert array_string.to_value_type() == ValueTypeProto.Enum.Value("STRING_LIST")
assert from_value_type(array_string.to_value_type()) == array_string
with pytest.raises(ValueError):
_ = Array(Array)
with pytest.raises(ValueError):
_ = Array(Array(String))
def test_all_value_types():
values = ValueTypeProto.Enum.values()
for value in values:
# We do not support the NULL type.
if value != ValueTypeProto.Enum.Value("NULL"):
assert from_value_type(value).to_value_type() == value