@@ -225,7 +225,7 @@ class WebsiteIndex(AlgoliaIndex):
225225 self .index = WebsiteIndex (Website , self .client , settings .ALGOLIA )
226226
227227 # Given some existing query rules on the index
228- self . index .__client .save_rule ()
228+ # index.__index .save_rule() # TODO: Check query rules are kept
229229
230230 # Given some existing settings on the index
231231 existing_settings = self .apply_some_settings (self .index )
@@ -237,7 +237,13 @@ class WebsiteIndex(AlgoliaIndex):
237237 # Expect the settings to be reset to model definition over reindex
238238 former_settings = existing_settings
239239 former_settings ["hitsPerPage" ] = 15
240- self .assertDictEqual (self .index .get_settings (), former_settings )
240+
241+ new_settings = self .index .get_settings ()
242+
243+ self .assertIsNotNone (new_settings )
244+
245+ if new_settings is not None :
246+ self .assertDictEqual (new_settings , former_settings )
241247
242248 def test_reindex_with_rules (self ):
243249 # Given an existing index defined with settings
@@ -253,6 +259,11 @@ class WebsiteIndex(AlgoliaIndex):
253259 "consequence" : {"params" : {"query" : "other text" }},
254260 }
255261
262+ self .assertIsNotNone (self .index .index_name )
263+
264+ if self .index .index_name is None :
265+ return
266+
256267 self .client .save_rule (self .index .index_name , rule ["objectID" ], rule )
257268
258269 # When reindexing with no settings on the instance
@@ -280,32 +291,37 @@ class WebsiteIndex(AlgoliaIndex):
280291
281292 self .index = WebsiteIndex (Website , self .client , settings .ALGOLIA )
282293
294+ self .assertIsNotNone (self .index .index_name )
295+
296+ if self .index .index_name is None :
297+ return
298+
283299 # Given some existing synonyms on the index
284300 synonym = {
285301 "objectID" : "street" ,
286302 "type" : "altCorrection1" ,
287303 "word" : "Street" ,
288304 "corrections" : ["St" ],
289305 }
290- self .index .__client .save_synonyms (
291- self .index .index_name , synonym ["objectID" ], synonym
292- )
306+ save_synonyms_response = self .client .save_synonyms (self .index .index_name , synonym_hit = [synonym ])
307+ self .client .wait_for_task (self .index .index_name , save_synonyms_response .task_id )
293308
294309 # When reindexing with no settings on the instance
295310 self .index = WebsiteIndex (Website , self .client , settings .ALGOLIA )
296311 self .index .reindex_all ()
297312
298313 # Expect the synonyms to be kept across reindex
314+ resp = self .client .search_synonyms (index_name = self .index .index_name )
315+ print (resp , self .index .index_name )
316+
299317 synonyms = []
300- self .index .__client .browse_synonyms (
301- self .index .index_name , lambda _resp : synonyms .extend (_resp .hits )
302- )
318+ self .client .browse_synonyms (self .index .index_name , lambda _resp : print (_resp ))
303319 self .assertEqual (len (synonyms ), 1 , "There should only be one synonym" )
304320 self .assertIn (
305321 synonym , synonyms , "The existing synonym should be kept over reindex"
306322 )
307323
308- def apply_some_settings (self , index ):
324+ def apply_some_settings (self , index ) -> dict :
309325 """
310326 Applies a sample setting to the index.
311327
0 commit comments