4
4
5
5
from django .db import connection
6
6
from django .db .utils import DatabaseError
7
- from django .test import TransactionTestCase
7
+ from django .test import TransactionTestCase , skipUnlessDBFeature
8
8
from pymongo .operations import SearchIndexModel
9
9
10
10
from django_mongodb_backend .expressions .search import (
@@ -65,6 +65,7 @@ def _inner_wait_loop(predicate: Callable):
65
65
return _inner_wait_loop
66
66
67
67
68
+ @skipUnlessDBFeature ("supports_atlas_search" )
68
69
class SearchUtilsMixin (TransactionTestCase ):
69
70
available_apps = []
70
71
@@ -87,6 +88,7 @@ def _tear_down(self, model):
87
88
wait_for_assertion = _wait_for_assertion (timeout = 3 )
88
89
89
90
91
+ @skipUnlessDBFeature ("supports_atlas_search" )
90
92
class SearchEqualsTest (SearchUtilsMixin ):
91
93
def setUp (self ):
92
94
self .create_search_index (
@@ -106,6 +108,7 @@ def test_search_equals(self):
106
108
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
107
109
108
110
111
+ @skipUnlessDBFeature ("supports_atlas_search" )
109
112
class SearchAutocompleteTest (SearchUtilsMixin ):
110
113
def setUp (self ):
111
114
self .create_search_index (
@@ -170,6 +173,7 @@ def test_search_autocomplete_embedded_model(self):
170
173
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
171
174
172
175
176
+ @skipUnlessDBFeature ("supports_atlas_search" )
173
177
class SearchExistsTest (SearchUtilsMixin ):
174
178
def setUp (self ):
175
179
self .create_search_index (
@@ -184,6 +188,7 @@ def test_search_exists(self):
184
188
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
185
189
186
190
191
+ @skipUnlessDBFeature ("supports_atlas_search" )
187
192
class SearchInTest (SearchUtilsMixin ):
188
193
def setUp (self ):
189
194
self .create_search_index (
@@ -203,6 +208,7 @@ def test_search_in(self):
203
208
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
204
209
205
210
211
+ @skipUnlessDBFeature ("supports_atlas_search" )
206
212
class SearchPhraseTest (SearchUtilsMixin ):
207
213
def setUp (self ):
208
214
self .create_search_index (
@@ -224,6 +230,7 @@ def test_search_phrase(self):
224
230
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
225
231
226
232
233
+ @skipUnlessDBFeature ("supports_atlas_search" )
227
234
class SearchRangeTest (SearchUtilsMixin ):
228
235
def setUp (self ):
229
236
self .create_search_index (
@@ -243,6 +250,7 @@ def test_search_range(self):
243
250
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .number20 ]))
244
251
245
252
253
+ @skipUnlessDBFeature ("supports_atlas_search" )
246
254
class SearchRegexTest (SearchUtilsMixin ):
247
255
def setUp (self ):
248
256
self .create_search_index (
@@ -269,6 +277,7 @@ def test_search_regex(self):
269
277
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
270
278
271
279
280
+ @skipUnlessDBFeature ("supports_atlas_search" )
272
281
class SearchTextTest (SearchUtilsMixin ):
273
282
def setUp (self ):
274
283
self .create_search_index (
@@ -298,6 +307,7 @@ def test_search_text_with_fuzzy_and_criteria(self):
298
307
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
299
308
300
309
310
+ @skipUnlessDBFeature ("supports_atlas_search" )
301
311
class SearchWildcardTest (SearchUtilsMixin ):
302
312
def setUp (self ):
303
313
self .create_search_index (
@@ -322,6 +332,7 @@ def test_search_wildcard(self):
322
332
self .wait_for_assertion (lambda : self .assertCountEqual ([self .article ], qs ))
323
333
324
334
335
+ @skipUnlessDBFeature ("supports_atlas_search" )
325
336
class SearchGeoShapeTest (SearchUtilsMixin ):
326
337
def setUp (self ):
327
338
self .create_search_index (
@@ -356,6 +367,7 @@ def test_search_geo_shape(self):
356
367
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
357
368
358
369
370
+ @skipUnlessDBFeature ("supports_atlas_search" )
359
371
class SearchGeoWithinTest (SearchUtilsMixin ):
360
372
def setUp (self ):
361
373
self .create_search_index (
@@ -389,6 +401,7 @@ def test_search_geo_within(self):
389
401
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
390
402
391
403
404
+ @skipUnlessDBFeature ("supports_atlas_search" )
392
405
@unittest .expectedFailure
393
406
class SearchMoreLikeThisTest (SearchUtilsMixin ):
394
407
def setUp (self ):
@@ -436,6 +449,7 @@ def test_search_more_like_this(self):
436
449
)
437
450
438
451
452
+ @skipUnlessDBFeature ("supports_atlas_search" )
439
453
class CompoundSearchTest (SearchUtilsMixin ):
440
454
def setUp (self ):
441
455
self .create_search_index (
@@ -505,6 +519,7 @@ def test_compound_operations(self):
505
519
)
506
520
507
521
522
+ @skipUnlessDBFeature ("supports_atlas_search" )
508
523
class SearchVectorTest (SearchUtilsMixin ):
509
524
def setUp (self ):
510
525
self .create_search_index (
0 commit comments