File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change
1
+ import datetime
2
+
1
3
from django .core .exceptions import FieldDoesNotExist
2
4
from django .db import connection
3
5
from django .test import TestCase
4
6
5
7
from django_mongodb_backend .indexes import AtlasSearchIndex
6
8
7
- from .models import Article
9
+ from .models import Article , Data
8
10
9
11
10
- class PartialIndexTests (TestCase ):
12
+ class AtlasIndexTests (TestCase ):
11
13
# Schema editor is used to create the index to test that it works.
12
14
# available_apps = ["indexes"]
13
15
available_apps = None
@@ -91,3 +93,20 @@ def test_field_not_exists(self):
91
93
FieldDoesNotExist , msg
92
94
), connection .schema_editor () as editor :
93
95
editor .add_index (index = index , model = Article )
96
+
97
+
98
+ class AtlasIndexTestsWithData (AtlasIndexTests ):
99
+ @classmethod
100
+ def setUpTestData (cls ):
101
+ articles = [
102
+ Article (
103
+ headline = f"Title { i } " ,
104
+ number = i ,
105
+ body = f"body { i } " ,
106
+ data = "{json: i}" ,
107
+ embedded = Data (integer = i ),
108
+ auto_now = datetime .datetime .now (),
109
+ )
110
+ for i in range (5 )
111
+ ]
112
+ cls .objs = Article .objects .bulk_create (articles )
You can’t perform that action at this time.
0 commit comments