Skip to content

Commit a4476c9

Browse files
committed
Test
1 parent e491c19 commit a4476c9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/indexes_/test_atlas_indexes.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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)

0 commit comments

Comments
 (0)