@@ -225,7 +225,7 @@ class WebsiteIndex(AlgoliaIndex):
225
225
self .index = WebsiteIndex (Website , self .client , settings .ALGOLIA )
226
226
227
227
# 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
229
229
230
230
# Given some existing settings on the index
231
231
existing_settings = self .apply_some_settings (self .index )
@@ -237,7 +237,13 @@ class WebsiteIndex(AlgoliaIndex):
237
237
# Expect the settings to be reset to model definition over reindex
238
238
former_settings = existing_settings
239
239
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 )
241
247
242
248
def test_reindex_with_rules (self ):
243
249
# Given an existing index defined with settings
@@ -253,6 +259,11 @@ class WebsiteIndex(AlgoliaIndex):
253
259
"consequence" : {"params" : {"query" : "other text" }},
254
260
}
255
261
262
+ self .assertIsNotNone (self .index .index_name )
263
+
264
+ if self .index .index_name is None :
265
+ return
266
+
256
267
self .client .save_rule (self .index .index_name , rule ["objectID" ], rule )
257
268
258
269
# When reindexing with no settings on the instance
@@ -280,32 +291,37 @@ class WebsiteIndex(AlgoliaIndex):
280
291
281
292
self .index = WebsiteIndex (Website , self .client , settings .ALGOLIA )
282
293
294
+ self .assertIsNotNone (self .index .index_name )
295
+
296
+ if self .index .index_name is None :
297
+ return
298
+
283
299
# Given some existing synonyms on the index
284
300
synonym = {
285
301
"objectID" : "street" ,
286
302
"type" : "altCorrection1" ,
287
303
"word" : "Street" ,
288
304
"corrections" : ["St" ],
289
305
}
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 )
293
308
294
309
# When reindexing with no settings on the instance
295
310
self .index = WebsiteIndex (Website , self .client , settings .ALGOLIA )
296
311
self .index .reindex_all ()
297
312
298
313
# 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
+
299
317
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 ))
303
319
self .assertEqual (len (synonyms ), 1 , "There should only be one synonym" )
304
320
self .assertIn (
305
321
synonym , synonyms , "The existing synonym should be kept over reindex"
306
322
)
307
323
308
- def apply_some_settings (self , index ):
324
+ def apply_some_settings (self , index ) -> dict :
309
325
"""
310
326
Applies a sample setting to the index.
311
327
0 commit comments