1010from elasticsearch .exceptions import NotFoundError
1111from elasticsearch_dsl import Index as DSLIndex
1212from django_elasticsearch_dsl .test import ESTestCase
13- from tests import ES_MAJOR_VERSION
13+ from django_elasticsearch_dsl . versions import ES_MAJOR_VERSION
1414
1515from .documents import (
1616 ad_index ,
3131 "--elasticsearch not set"
3232)
3333class IntegrationTestCase (ESTestCase , TestCase ):
34+
35+ maxDiff = None
36+
3437 def setUp (self ):
3538 super (IntegrationTestCase , self ).setUp ()
3639 self .manufacturer = Manufacturer (
@@ -103,7 +106,7 @@ def test_get_doc_with_reverse_relationships(self):
103106 result = s .execute ()
104107 self .assertEqual (len (result ), 1 )
105108 car1_doc = result [0 ]
106- self .assertEqual ( car1_doc .ads , [
109+ self .assertListEqual ( list ( car1_doc .ads ) , [
107110 {
108111 'title' : self .ad1 .title ,
109112 'description' : self .ad1 .description ,
@@ -123,7 +126,7 @@ def test_get_doc_with_many_to_many_relationships(self):
123126 result = s .execute ()
124127 self .assertEqual (len (result ), 1 )
125128 car1_doc = result [0 ]
126- self .assertEqual ( car1_doc .categories , [
129+ self .assertListEqual ( list ( car1_doc .categories ) , [
127130 {
128131 'title' : self .category1 .title ,
129132 'slug' : self .category1 .slug ,
@@ -141,7 +144,7 @@ def test_doc_to_dict(self):
141144 result = s .execute ()
142145 self .assertEqual (len (result ), 1 )
143146 car2_doc = result [0 ]
144- self .assertEqual (car2_doc .to_dict (), {
147+ self .assertDictEqual (car2_doc .to_dict (), {
145148 'type' : self .car2 .type ,
146149 'launched' : self .car2 .launched ,
147150 'name' : self .car2 .name ,
@@ -160,7 +163,7 @@ def test_doc_to_dict(self):
160163 result = s .execute ()
161164 self .assertEqual (len (result ), 1 )
162165 car3_doc = result [0 ]
163- self .assertEqual (car3_doc .to_dict (), {
166+ self .assertDictEqual (car3_doc .to_dict (), {
164167 'type' : self .car3 .type ,
165168 'launched' : self .car3 .launched ,
166169 'name' : self .car3 .name ,
@@ -188,7 +191,7 @@ def test_index_to_dict(self):
188191
189192 index_dict = test_index .to_dict ()
190193
191- self .assertEqual (index_dict ['settings' ], {
194+ self .assertDictEqual (index_dict ['settings' ], {
192195 'number_of_shards' : 1 ,
193196 'number_of_replicas' : 0 ,
194197 'analysis' : {
@@ -203,7 +206,14 @@ def test_index_to_dict(self):
203206 }
204207 }
205208 })
206- self .assertEqual (index_dict ['mappings' ], {
209+
210+ index_dict_mappings = index_dict ['mappings' ]
211+ if ES_MAJOR_VERSION < 7 :
212+ index_dict_mappings = index_dict_mappings ['doc' ]
213+
214+ self .assertDictEqual (
215+ index_dict_mappings ,
216+ {
207217 'properties' : {
208218 'ads' : {
209219 'type' : 'nested' ,
@@ -235,7 +245,8 @@ def test_index_to_dict(self):
235245 'launched' : {'type' : 'date' },
236246 'type' : {'type' : text_type }
237247 }
238- })
248+ }
249+ )
239250
240251 def test_related_docs_are_updated (self ):
241252 # test foreignkey relation
0 commit comments