1- NEW_SETTINGS = {
2- "rankingRules" : ["typo" , "words" ],
3- "searchableAttributes" : ["title" , "overview" ],
4- }
1+ import pytest
2+
3+ from meilisearch .models .index import HuggingFaceEmbedder , OpenAiEmbedder , UserProvidedEmbedder
4+
5+
6+ @pytest .fixture
7+ def new_settings (new_embedders ):
8+ return {
9+ "rankingRules" : ["typo" , "words" ],
10+ "searchableAttributes" : ["title" , "overview" ],
11+ "embedders" : new_embedders ,
12+ }
13+
514
615DEFAULT_RANKING_RULES = ["words" , "typo" , "proximity" , "attribute" , "sort" , "exactness" ]
716
@@ -31,36 +40,41 @@ def test_get_settings_default(empty_index):
3140 assert response ["synonyms" ] == {}
3241
3342
34- def test_update_settings (empty_index ):
43+ @pytest .mark .usefixtures ("enable_vector_search" )
44+ def test_update_settings (new_settings , empty_index ):
3545 """Tests updating some settings."""
3646 index = empty_index ()
37- response = index .update_settings (NEW_SETTINGS )
47+ response = index .update_settings (new_settings )
3848 update = index .wait_for_task (response .task_uid )
3949 assert update .status == "succeeded"
4050 response = index .get_settings ()
41- for rule in NEW_SETTINGS ["rankingRules" ]:
51+ for rule in new_settings ["rankingRules" ]:
4252 assert rule in response ["rankingRules" ]
4353 assert response ["distinctAttribute" ] is None
44- for attribute in NEW_SETTINGS ["searchableAttributes" ]:
54+ for attribute in new_settings ["searchableAttributes" ]:
4555 assert attribute in response ["searchableAttributes" ]
4656 assert response ["displayedAttributes" ] == ["*" ]
4757 assert response ["stopWords" ] == []
4858 assert response ["synonyms" ] == {}
59+ assert isinstance (response ["embedders" ]["default" ], UserProvidedEmbedder )
60+ assert isinstance (response ["embedders" ]["open_ai" ], OpenAiEmbedder )
61+ assert isinstance (response ["embedders" ]["hugging_face" ], HuggingFaceEmbedder )
4962
5063
51- def test_reset_settings (empty_index ):
64+ @pytest .mark .usefixtures ("enable_vector_search" )
65+ def test_reset_settings (new_settings , empty_index ):
5266 """Tests resetting all the settings to their default value."""
5367 index = empty_index ()
5468 # Update settings first
55- response = index .update_settings (NEW_SETTINGS )
69+ response = index .update_settings (new_settings )
5670 update = index .wait_for_task (response .task_uid )
5771 assert update .status == "succeeded"
5872 # Check the settings have been correctly updated
5973 response = index .get_settings ()
60- for rule in NEW_SETTINGS ["rankingRules" ]:
74+ for rule in new_settings ["rankingRules" ]:
6175 assert rule in response ["rankingRules" ]
6276 assert response ["distinctAttribute" ] is None
63- for attribute in NEW_SETTINGS ["searchableAttributes" ]:
77+ for attribute in new_settings ["searchableAttributes" ]:
6478 assert attribute in response ["searchableAttributes" ]
6579 assert response ["displayedAttributes" ] == ["*" ]
6680 assert response ["stopWords" ] == []
@@ -80,3 +94,4 @@ def test_reset_settings(empty_index):
8094 assert response ["searchableAttributes" ] == ["*" ]
8195 assert response ["stopWords" ] == []
8296 assert response ["synonyms" ] == {}
97+ assert response .get ("embedders" ) is None
0 commit comments