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 (
@@ -105,6 +107,7 @@ def test_search_equals(self):
105
107
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
106
108
107
109
110
+ @skipUnlessDBFeature ("supports_atlas_search" )
108
111
class SearchAutocompleteTest (SearchUtilsMixin ):
109
112
def setUp (self ):
110
113
self .create_search_index (
@@ -168,6 +171,7 @@ def test_search_autocomplete_embedded_model(self):
168
171
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
169
172
170
173
174
+ @skipUnlessDBFeature ("supports_atlas_search" )
171
175
class SearchExistsTest (SearchUtilsMixin ):
172
176
def setUp (self ):
173
177
self .create_search_index (
@@ -182,6 +186,7 @@ def test_search_exists(self):
182
186
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
183
187
184
188
189
+ @skipUnlessDBFeature ("supports_atlas_search" )
185
190
class SearchInTest (SearchUtilsMixin ):
186
191
def setUp (self ):
187
192
self .create_search_index (
@@ -201,6 +206,7 @@ def test_search_in(self):
201
206
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .cross ]))
202
207
203
208
209
+ @skipUnlessDBFeature ("supports_atlas_search" )
204
210
class SearchPhraseTest (SearchUtilsMixin ):
205
211
def setUp (self ):
206
212
self .create_search_index (
@@ -221,6 +227,7 @@ def test_search_phrase(self):
221
227
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .irrelevant ]))
222
228
223
229
230
+ @skipUnlessDBFeature ("supports_atlas_search" )
224
231
class SearchRangeTest (SearchUtilsMixin ):
225
232
def setUp (self ):
226
233
self .create_search_index (
@@ -240,6 +247,7 @@ def test_search_range(self):
240
247
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .number20 ]))
241
248
242
249
250
+ @skipUnlessDBFeature ("supports_atlas_search" )
243
251
class SearchRegexTest (SearchUtilsMixin ):
244
252
def setUp (self ):
245
253
self .create_search_index (
@@ -265,6 +273,7 @@ def test_search_regex(self):
265
273
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
266
274
267
275
276
+ @skipUnlessDBFeature ("supports_atlas_search" )
268
277
class SearchTextTest (SearchUtilsMixin ):
269
278
def setUp (self ):
270
279
self .create_search_index (
@@ -293,6 +302,7 @@ def test_search_text_with_fuzzy_and_criteria(self):
293
302
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
294
303
295
304
305
+ @skipUnlessDBFeature ("supports_atlas_search" )
296
306
class SearchWildcardTest (SearchUtilsMixin ):
297
307
def setUp (self ):
298
308
self .create_search_index (
@@ -316,6 +326,7 @@ def test_search_wildcard(self):
316
326
self .wait_for_assertion (lambda : self .assertCountEqual ([self .article ], qs ))
317
327
318
328
329
+ @skipUnlessDBFeature ("supports_atlas_search" )
319
330
class SearchGeoShapeTest (SearchUtilsMixin ):
320
331
def setUp (self ):
321
332
self .create_search_index (
@@ -347,6 +358,7 @@ def test_search_geo_shape(self):
347
358
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
348
359
349
360
361
+ @skipUnlessDBFeature ("supports_atlas_search" )
350
362
class SearchGeoWithinTest (SearchUtilsMixin ):
351
363
def setUp (self ):
352
364
self .create_search_index (
@@ -377,6 +389,7 @@ def test_search_geo_within(self):
377
389
self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
378
390
379
391
392
+ @skipUnlessDBFeature ("supports_atlas_search" )
380
393
@unittest .expectedFailure
381
394
class SearchMoreLikeThisTest (SearchUtilsMixin ):
382
395
def setUp (self ):
@@ -424,6 +437,7 @@ def test_search_more_like_this(self):
424
437
)
425
438
426
439
440
+ @skipUnlessDBFeature ("supports_atlas_search" )
427
441
class CompoundSearchTest (SearchUtilsMixin ):
428
442
def setUp (self ):
429
443
self .create_search_index (
@@ -493,6 +507,7 @@ def test_compound_operations(self):
493
507
)
494
508
495
509
510
+ @skipUnlessDBFeature ("supports_atlas_search" )
496
511
class SearchVectorTest (SearchUtilsMixin ):
497
512
def setUp (self ):
498
513
self .create_search_index (
0 commit comments