44from pydantic import ValidationError
55
66from weaviate .collections .classes .config import (
7- _AsyncReplicationConfig ,
8- _ReplicationConfig ,
9- _ReplicationConfigUpdate ,
107 Configure ,
118 DataType ,
129 Property ,
1310 Reconfigure ,
1411 ReferenceProperty ,
15- TextAnalyzerConfig ,
1612 Tokenization ,
1713 Vectorizers ,
14+ _AsyncReplicationConfig ,
1815 _CollectionConfigCreate ,
1916 _GenerativeProvider ,
17+ _ReplicationConfig ,
18+ _ReplicationConfigUpdate ,
2019 _RerankerProvider ,
20+ _TextAnalyzerConfigCreate ,
2121 _VectorizerConfigCreate ,
2222 _ReplicationConfigCreate ,
2323 ReplicationDeletionStrategy ,
@@ -3025,7 +3025,7 @@ def test_nested_property_with_id_name_is_allowed() -> None:
30253025 assert prop .nestedProperties [0 ].name == "id"
30263026
30273027
3028- class TestTextAnalyzerConfig :
3028+ class Test_TextAnalyzerConfigCreate :
30293029 def test_property_without_text_analyzer_omits_key (self ) -> None :
30303030 prop = Property (name = "title" , data_type = DataType .TEXT )
30313031 assert "textAnalyzer" not in prop ._to_dict ()
@@ -3034,7 +3034,7 @@ def test_property_with_ascii_fold_only(self) -> None:
30343034 prop = Property (
30353035 name = "title" ,
30363036 data_type = DataType .TEXT ,
3037- text_analyzer = TextAnalyzerConfig ( ascii_fold = True ),
3037+ text_analyzer = Configure . TextAnalyzer . ascii_fold ( ),
30383038 )
30393039 assert prop ._to_dict ()["textAnalyzer" ] == {"asciiFold" : True }
30403040
@@ -3043,7 +3043,7 @@ def test_property_with_ascii_fold_and_ignore(self) -> None:
30433043 name = "title" ,
30443044 data_type = DataType .TEXT ,
30453045 tokenization = Tokenization .WORD ,
3046- text_analyzer = TextAnalyzerConfig ( ascii_fold = True , ascii_fold_ignore = ["é" , "ñ" ]),
3046+ text_analyzer = Configure . TextAnalyzer . ascii_fold ( ignore = ["é" , "ñ" ]),
30473047 )
30483048 out = prop ._to_dict ()
30493049 assert out ["textAnalyzer" ] == {
@@ -3052,22 +3052,9 @@ def test_property_with_ascii_fold_and_ignore(self) -> None:
30523052 }
30533053 assert out ["tokenization" ] == "word"
30543054
3055- def test_text_analyzer_default_omits_unset_fields (self ) -> None :
3056- prop = Property (
3057- name = "title" ,
3058- data_type = DataType .TEXT ,
3059- text_analyzer = TextAnalyzerConfig (),
3060- )
3061- # exclude_none drops both unset fields, leaving an empty dict
3062- assert prop ._to_dict ()["textAnalyzer" ] == {}
3063-
3064- def test_text_analyzer_only_ignore_list (self ) -> None :
3065- prop = Property (
3066- name = "title" ,
3067- data_type = DataType .TEXT ,
3068- text_analyzer = TextAnalyzerConfig (ascii_fold_ignore = ["é" ]),
3069- )
3070- assert prop ._to_dict ()["textAnalyzer" ] == {"asciiFoldIgnore" : ["é" ]}
3055+ def test_text_analyzer_rejects_ignore_without_ascii_fold (self ) -> None :
3056+ with pytest .raises (ValidationError ):
3057+ _TextAnalyzerConfigCreate (ascii_fold_ignore = ["é" ])
30713058
30723059 def test_nested_property_with_text_analyzer (self ) -> None :
30733060 prop = Property (
@@ -3077,7 +3064,7 @@ def test_nested_property_with_text_analyzer(self) -> None:
30773064 Property (
30783065 name = "title" ,
30793066 data_type = DataType .TEXT ,
3080- text_analyzer = TextAnalyzerConfig ( ascii_fold = True , ascii_fold_ignore = ["ñ" ]),
3067+ text_analyzer = Configure . TextAnalyzer . ascii_fold ( ignore = ["ñ" ]),
30813068 ),
30823069 ],
30833070 )
@@ -3087,13 +3074,8 @@ def test_nested_property_with_text_analyzer(self) -> None:
30873074 "asciiFoldIgnore" : ["ñ" ],
30883075 }
30893076
3090- def test_text_analyzer_accepts_snake_case_alias (self ) -> None :
3091- ta = TextAnalyzerConfig (ascii_fold = True , ascii_fold_ignore = ["é" ])
3092- assert ta .asciiFold is True
3093- assert ta .asciiFoldIgnore == ["é" ]
3094-
30953077 def test_text_analyzer_rejects_wrong_types (self ) -> None :
30963078 with pytest .raises (ValidationError ):
3097- TextAnalyzerConfig (ascii_fold = "yes" ) # type: ignore[arg-type]
3079+ _TextAnalyzerConfigCreate (ascii_fold = "yes" ) # type: ignore[arg-type]
30983080 with pytest .raises (ValidationError ):
3099- TextAnalyzerConfig (ascii_fold_ignore = "é" ) # type: ignore[arg-type]
3081+ _TextAnalyzerConfigCreate (ascii_fold_ignore = "é" ) # type: ignore[arg-type]
0 commit comments