-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_types.py
More file actions
50 lines (35 loc) · 1.55 KB
/
test_types.py
File metadata and controls
50 lines (35 loc) · 1.55 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pytest
from feast.types import Array, Float32, Set, String, from_value_type
from feast.value_type import ValueType
def test_primitive_feast_type():
assert String.to_value_type() == ValueType.STRING
assert from_value_type(String.to_value_type()) == String
assert Float32.to_value_type() == ValueType.FLOAT
assert from_value_type(Float32.to_value_type()) == Float32
def test_array_feast_type():
array_string = Array(String)
assert array_string.to_value_type() == ValueType.STRING_LIST
assert from_value_type(array_string.to_value_type()) == array_string
array_float_32 = Array(Float32)
assert array_float_32.to_value_type() == ValueType.FLOAT_LIST
assert from_value_type(array_float_32.to_value_type()) == array_float_32
with pytest.raises(ValueError):
_ = Array(Array)
with pytest.raises(ValueError):
_ = Array(Array(String))
def test_set_feast_type():
set_string = Set(String)
assert set_string.to_value_type() == ValueType.STRING_SET
assert from_value_type(set_string.to_value_type()) == set_string
set_float_32 = Set(Float32)
assert set_float_32.to_value_type() == ValueType.FLOAT_SET
assert from_value_type(set_float_32.to_value_type()) == set_float_32
with pytest.raises(ValueError):
_ = Set(Set)
with pytest.raises(ValueError):
_ = Set(Set(String))
def test_all_value_types():
for value in ValueType:
# We do not support the NULL type.
if value != ValueType.NULL:
assert from_value_type(value).to_value_type() == value