File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ from django .db import connection
2
+ from django .test import TransactionTestCase
3
+ from django .test .utils import override_settings
4
+
5
+ from django_mongodb_backend .indexes import AtlasSearchIndex
6
+
7
+ from .models import Article
8
+
9
+
10
+ @override_settings (USE_TZ = True )
11
+ class PartialIndexTests (TransactionTestCase ):
12
+ # Schema editor is used to create the index to test that it works.
13
+ # available_apps = ["indexes"]
14
+ available_apps = None
15
+
16
+ def test_partial_index (self ):
17
+ with connection .schema_editor () as editor :
18
+ index = AtlasSearchIndex (
19
+ name = "recent_article_idx" ,
20
+ fields = ["number" ],
21
+ )
22
+ editor .add_index (index = index , model = Article )
23
+ # with connection.cursor() as cursor:
24
+ # self.assertIn(
25
+ # index.name,
26
+ # connection.introspection.get_constraints(
27
+ # cursor=cursor,
28
+ # table_name=Article._meta.db_table,
29
+ # ),
30
+ # )
31
+ editor .remove_index (index = index , model = Article )
You can’t perform that action at this time.
0 commit comments