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 (
@@ -106,6 +108,7 @@ def test_search_equals(self):
106108 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
107109
108110
111+ @skipUnlessDBFeature ("supports_atlas_search" )
109112class SearchAutocompleteTest (SearchUtilsMixin ):
110113 def setUp (self ):
111114 self .create_search_index (
@@ -170,6 +173,7 @@ def test_search_autocomplete_embedded_model(self):
170173 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
171174
172175
176+ @skipUnlessDBFeature ("supports_atlas_search" )
173177class SearchExistsTest (SearchUtilsMixin ):
174178 def setUp (self ):
175179 self .create_search_index (
@@ -184,6 +188,7 @@ def test_search_exists(self):
184188 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
185189
186190
191+ @skipUnlessDBFeature ("supports_atlas_search" )
187192class SearchInTest (SearchUtilsMixin ):
188193 def setUp (self ):
189194 self .create_search_index (
@@ -203,6 +208,7 @@ def test_search_in(self):
203208 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
204209
205210
211+ @skipUnlessDBFeature ("supports_atlas_search" )
206212class SearchPhraseTest (SearchUtilsMixin ):
207213 def setUp (self ):
208214 self .create_search_index (
@@ -224,6 +230,7 @@ def test_search_phrase(self):
224230 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
225231
226232
233+ @skipUnlessDBFeature ("supports_atlas_search" )
227234class SearchRangeTest (SearchUtilsMixin ):
228235 def setUp (self ):
229236 self .create_search_index (
@@ -243,6 +250,7 @@ def test_search_range(self):
243250 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .number20 ]))
244251
245252
253+ @skipUnlessDBFeature ("supports_atlas_search" )
246254class SearchRegexTest (SearchUtilsMixin ):
247255 def setUp (self ):
248256 self .create_search_index (
@@ -269,6 +277,7 @@ def test_search_regex(self):
269277 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
270278
271279
280+ @skipUnlessDBFeature ("supports_atlas_search" )
272281class SearchTextTest (SearchUtilsMixin ):
273282 def setUp (self ):
274283 self .create_search_index (
@@ -298,6 +307,7 @@ def test_search_text_with_fuzzy_and_criteria(self):
298307 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
299308
300309
310+ @skipUnlessDBFeature ("supports_atlas_search" )
301311class SearchWildcardTest (SearchUtilsMixin ):
302312 def setUp (self ):
303313 self .create_search_index (
@@ -322,6 +332,7 @@ def test_search_wildcard(self):
322332 self .wait_for_assertion (lambda : self .assertCountEqual ([self .article ], qs ))
323333
324334
335+ @skipUnlessDBFeature ("supports_atlas_search" )
325336class SearchGeoShapeTest (SearchUtilsMixin ):
326337 def setUp (self ):
327338 self .create_search_index (
@@ -356,6 +367,7 @@ def test_search_geo_shape(self):
356367 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
357368
358369
370+ @skipUnlessDBFeature ("supports_atlas_search" )
359371class SearchGeoWithinTest (SearchUtilsMixin ):
360372 def setUp (self ):
361373 self .create_search_index (
@@ -389,6 +401,7 @@ def test_search_geo_within(self):
389401 self .wait_for_assertion (lambda : self .assertCountEqual (qs .all (), [self .article ]))
390402
391403
404+ @skipUnlessDBFeature ("supports_atlas_search" )
392405@unittest .expectedFailure
393406class SearchMoreLikeThisTest (SearchUtilsMixin ):
394407 def setUp (self ):
@@ -436,6 +449,7 @@ def test_search_more_like_this(self):
436449 )
437450
438451
452+ @skipUnlessDBFeature ("supports_atlas_search" )
439453class CompoundSearchTest (SearchUtilsMixin ):
440454 def setUp (self ):
441455 self .create_search_index (
@@ -505,6 +519,7 @@ def test_compound_operations(self):
505519 )
506520
507521
522+ @skipUnlessDBFeature ("supports_atlas_search" )
508523class SearchVectorTest (SearchUtilsMixin ):
509524 def setUp (self ):
510525 self .create_search_index (
0 commit comments