44
55from django .db import connection
66from django .db .utils import DatabaseError
7- from django .test import TransactionTestCase
7+ from django .test import TransactionTestCase , skipUnlessDBFeature
88from pymongo .operations import SearchIndexModel
99
1010from django_mongodb_backend .expressions .search import (
@@ -65,6 +65,7 @@ def _inner_wait_loop(predicate: Callable):
6565 return _inner_wait_loop
6666
6767
68+ @skipUnlessDBFeature ("supports_atlas_search" )
6869class SearchUtilsMixin (TransactionTestCase ):
6970 available_apps = []
7071
@@ -87,6 +88,7 @@ def _tear_down(self, model):
8788 wait_for_assertion = _wait_for_assertion (timeout = 3 )
8889
8990
91+ @skipUnlessDBFeature ("supports_atlas_search" )
9092class SearchEqualsTest (SearchUtilsMixin ):
9193 def setUp (self ):
9294 self .create_search_index (
@@ -105,6 +107,7 @@ def test_search_equals(self):
105107 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
106108
107109
110+ @skipUnlessDBFeature ("supports_atlas_search" )
108111class SearchAutocompleteTest (SearchUtilsMixin ):
109112 def setUp (self ):
110113 self .create_search_index (
@@ -168,6 +171,7 @@ def test_search_autocomplete_embedded_model(self):
168171 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
169172
170173
174+ @skipUnlessDBFeature ("supports_atlas_search" )
171175class SearchExistsTest (SearchUtilsMixin ):
172176 def setUp (self ):
173177 self .create_search_index (
@@ -182,6 +186,7 @@ def test_search_exists(self):
182186 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
183187
184188
189+ @skipUnlessDBFeature ("supports_atlas_search" )
185190class SearchInTest (SearchUtilsMixin ):
186191 def setUp (self ):
187192 self .create_search_index (
@@ -201,6 +206,7 @@ def test_search_in(self):
201206 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .cross ]))
202207
203208
209+ @skipUnlessDBFeature ("supports_atlas_search" )
204210class SearchPhraseTest (SearchUtilsMixin ):
205211 def setUp (self ):
206212 self .create_search_index (
@@ -221,6 +227,7 @@ def test_search_phrase(self):
221227 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .irrelevant ]))
222228
223229
230+ @skipUnlessDBFeature ("supports_atlas_search" )
224231class SearchRangeTest (SearchUtilsMixin ):
225232 def setUp (self ):
226233 self .create_search_index (
@@ -240,6 +247,7 @@ def test_search_range(self):
240247 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .number20 ]))
241248
242249
250+ @skipUnlessDBFeature ("supports_atlas_search" )
243251class SearchRegexTest (SearchUtilsMixin ):
244252 def setUp (self ):
245253 self .create_search_index (
@@ -265,6 +273,7 @@ def test_search_regex(self):
265273 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
266274
267275
276+ @skipUnlessDBFeature ("supports_atlas_search" )
268277class SearchTextTest (SearchUtilsMixin ):
269278 def setUp (self ):
270279 self .create_search_index (
@@ -293,6 +302,7 @@ def test_search_text_with_fuzzy_and_criteria(self):
293302 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
294303
295304
305+ @skipUnlessDBFeature ("supports_atlas_search" )
296306class SearchWildcardTest (SearchUtilsMixin ):
297307 def setUp (self ):
298308 self .create_search_index (
@@ -316,6 +326,7 @@ def test_search_wildcard(self):
316326 self .wait_for_assertion (lambda : self .assertCountEqual ([self .article ], qs ))
317327
318328
329+ @skipUnlessDBFeature ("supports_atlas_search" )
319330class SearchGeoShapeTest (SearchUtilsMixin ):
320331 def setUp (self ):
321332 self .create_search_index (
@@ -347,6 +358,7 @@ def test_search_geo_shape(self):
347358 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
348359
349360
361+ @skipUnlessDBFeature ("supports_atlas_search" )
350362class SearchGeoWithinTest (SearchUtilsMixin ):
351363 def setUp (self ):
352364 self .create_search_index (
@@ -377,6 +389,7 @@ def test_search_geo_within(self):
377389 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
378390
379391
392+ @skipUnlessDBFeature ("supports_atlas_search" )
380393@unittest .expectedFailure
381394class SearchMoreLikeThisTest (SearchUtilsMixin ):
382395 def setUp (self ):
@@ -424,6 +437,7 @@ def test_search_more_like_this(self):
424437 )
425438
426439
440+ @skipUnlessDBFeature ("supports_atlas_search" )
427441class CompoundSearchTest (SearchUtilsMixin ):
428442 def setUp (self ):
429443 self .create_search_index (
@@ -493,6 +507,7 @@ def test_compound_operations(self):
493507 )
494508
495509
510+ @skipUnlessDBFeature ("supports_atlas_search" )
496511class SearchVectorTest (SearchUtilsMixin ):
497512 def setUp (self ):
498513 self .create_search_index (
0 commit comments