Skip to content

Commit b0f6dbd

Browse files
committed
Add test with data
1 parent 0ed75f0 commit b0f6dbd

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tests/indexes_/test_atlas_indexes.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import datetime
2+
13
from django.core.exceptions import FieldDoesNotExist
24
from django.db import connection
35
from django.test import TestCase
46

57
from 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)

0 commit comments

Comments
 (0)