33
44import pytest
55
6- from redisvl .schema .fields import NumericField , TagField , TextField
7- from redisvl .schema .schema import IndexSchema , StorageType
6+ from redisvl .schema .fields import TagField , TextField
7+ from redisvl .schema .schema import IndexSchema , StorageType , custom_dict
88
99
1010def get_base_path ():
@@ -16,6 +16,12 @@ def create_sample_index_schema():
1616 sample_fields = [
1717 {"name" : "example_text" , "type" : "text" , "attrs" : {"sortable" : False }},
1818 {"name" : "example_numeric" , "type" : "numeric" , "attrs" : {"sortable" : True }},
19+ {"name" : "example_tag" , "type" : "tag" , "attrs" : {"sortable" : True }},
20+ {
21+ "name" : "example_vector" ,
22+ "type" : "vector" ,
23+ "attrs" : {"dims" : 1024 , "algorithm" : "flat" },
24+ },
1925 ]
2026 return IndexSchema .from_dict ({"index" : {"name" : "test" }, "fields" : sample_fields })
2127
@@ -89,26 +95,6 @@ def test_remove_field():
8995 assert "example_text" not in index_schema .field_names
9096
9197
92- def test_schema_compare ():
93- """Test schema comparisons."""
94- schema_1 = IndexSchema .from_dict ({"index" : {"name" : "test" }})
95- # manually add the same fields as the helper method provides below
96- schema_1 .add_fields (
97- [
98- {"name" : "example_text" , "type" : "text" , "attrs" : {"sortable" : False }},
99- {"name" : "example_numeric" , "type" : "numeric" , "attrs" : {"sortable" : True }},
100- ]
101- )
102-
103- assert "example_text" in schema_1 .fields
104- assert "example_numeric" in schema_1 .fields
105-
106- schema_2 = create_sample_index_schema ()
107- assert schema_1 .fields == schema_2 .fields
108- assert schema_1 .index .name == schema_2 .index .name
109- assert schema_1 .to_dict () == schema_2 .to_dict ()
110-
111-
11298def test_generate_fields ():
11399 """Test field generation."""
114100 sample = {"name" : "John" , "age" : 30 , "tags" : ["test" , "test2" ]}
@@ -126,7 +112,7 @@ def test_to_dict():
126112 index_dict = index_schema .to_dict ()
127113 assert index_dict ["index" ]["name" ] == "test"
128114 assert isinstance (index_dict ["fields" ], list )
129- assert len (index_dict ["fields" ]) == 2 == len (index_schema .fields )
115+ assert len (index_dict ["fields" ]) == 4 == len (index_schema .fields )
130116
131117
132118def test_from_dict ():
0 commit comments