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+
13from django .core .exceptions import FieldDoesNotExist
24from django .db import connection
35from django .test import TestCase
46
57from django_mongodb_backend .indexes import AtlasSearchIndex
68
7- from .models import Article
9+ from .models import Article , Data
810
911
10- class PartialIndexTests (TestCase ):
12+ class AtlasIndexTests (TestCase ):
1113 # Schema editor is used to create the index to test that it works.
1214 # available_apps = ["indexes"]
1315 available_apps = None
@@ -91,3 +93,20 @@ def test_field_not_exists(self):
9193 FieldDoesNotExist , msg
9294 ), connection .schema_editor () as editor :
9395 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