Skip to content

Commit dbbbfac

Browse files
committed
remove Version check
1 parent 7bf5ea3 commit dbbbfac

File tree

6 files changed

+35
-87
lines changed

6 files changed

+35
-87
lines changed

.travis.yml

Lines changed: 14 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,37 @@
11
# Config file for automatic testing at travis-ci.org
22

33
language: python
4-
python: 3.8
4+
python: 3.7
55

66
dist: xenial # default "precise" distro doesn't include Java 8 for Elasticsearch 5
77

88
matrix:
99
include:
10-
- env: TOX_ENV=py36-django-111-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
10+
- env: TOX_ENV=py36-django-110-es6
1111
python: 3.6
12-
- env: TOX_ENV=py36-django-111-es7
13-
python: 3.6
14-
15-
- env: TOX_ENV=py37-django-111-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
16-
python: 3.7
17-
- env: TOX_ENV=py37-django-111-es7
12+
- env: TOX_ENV=py37-django-110-es6
1813
python: 3.7
19-
20-
- env: TOX_ENV=py38-django-111-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
21-
python: 3.8
22-
- env: TOX_ENV=py38-django-111-es7
23-
python: 3.8
24-
25-
- env: TOX_ENV=py27-django-111-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
26-
python: 2.7
27-
- env: TOX_ENV=py27-django-111-es7
14+
- env: TOX_ENV=py27-django-110-es6
2815
python: 2.7
29-
30-
- env: TOX_ENV=py36-django-2-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
31-
python: 3.6
32-
- env: TOX_ENV=py36-django-2-es7
16+
- env: TOX_ENV=py36-django-111-es6
3317
python: 3.6
34-
35-
- env: TOX_ENV=py37-django-2-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
36-
python: 3.7
37-
- env: TOX_ENV=py37-django-2-es7
38-
python: 3.7
39-
40-
- env: TOX_ENV=py37-django-21-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
41-
python: 3.7
42-
- env: TOX_ENV=py37-django-21-es7
18+
- env: TOX_ENV=py37-django-111-es6
4319
python: 3.7
44-
45-
- env: TOX_ENV=py37-django-22-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
20+
- env: TOX_ENV=py27-django-111-es6
21+
python: 2.7
22+
- env: TOX_ENV=py36-django-2-es6
23+
python: 3.6
24+
- env: TOX_ENV=py37-django-2-es6
4625
python: 3.7
47-
- env: TOX_ENV=py37-django-22-es7
26+
- env: TOX_ENV=py37-django-21-es6
4827
python: 3.7
49-
50-
- env: TOX_ENV=py37-django-30-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
28+
- env: TOX_ENV=py37-django-22-es6
5129
python: 3.7
52-
- env: TOX_ENV=py37-django-30-es7
53-
python: 3.7
54-
55-
- env: TOX_ENV=py38-django-2-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
56-
python: 3.8
57-
- env: TOX_ENV=py38-django-2-es7
58-
python: 3.8
59-
60-
- env: TOX_ENV=py38-django-21-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
61-
python: 3.8
62-
- env: TOX_ENV=py38-django-21-es7
63-
python: 3.8
64-
65-
- env: TOX_ENV=py38-django-22-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
66-
python: 3.8
67-
- env: TOX_ENV=py38-django-22-es7
68-
python: 3.8
69-
70-
- env: TOX_ENV=py38-django-30-es6 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
71-
python: 3.8
72-
- env: TOX_ENV=py38-django-30-es7
73-
python: 3.8
7430

7531
cache: pip
7632
env:
7733
global:
78-
- ES_APT_URL=https://artifacts.elastic.co/packages/7.x/apt
34+
- ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
7935

8036
before_install:
8137
# work around https://github.com/travis-ci/travis-ci/issues/8363

django_elasticsearch_dsl/documents.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,22 @@ def parallel_bulk(self, actions, **kwargs):
160160
@classmethod
161161
def generate_id(cls, object_instance):
162162
"""
163-
The default behavior is to use the Django object's pk (id) as the
164-
elasticseach index id (_id). If needed, this method can be overloaded
163+
The default behavior is to use the Django object's pk (id) as the
164+
elasticseach index id (_id). If needed, this method can be overloaded
165165
to change this default behavior.
166166
"""
167167
return object_instance.pk
168168

169169
def _prepare_action(self, object_instance, action):
170-
_val = {
170+
return {
171171
'_op_type': action,
172172
'_index': self._index._name,
173173
'_id': self.generate_id(object_instance),
174+
'_type': self._doc_type.name,
174175
'_source': (
175176
self.prepare(object_instance) if action != 'delete' else None
176177
),
177178
}
178-
if ES_MAJOR_VERSION < 7:
179-
_val['_type'] = self._doc_type.name
180-
return _val
181179

182180
def _get_actions(self, object_list, action):
183181
for object_instance in object_list:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
],
4343
include_package_data=True,
4444
install_requires=[
45-
'elasticsearch-dsl>=6.4.0<8.0.0',
45+
'elasticsearch-dsl>=6.4.0<7.0.0',
4646
'six',
4747
],
4848
license="Apache Software License 2.0",

tests/test_documents.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ def test_to_field_with_unknown_field(self):
138138
def test_mapping(self):
139139
text_type = 'string' if ES_MAJOR_VERSION == 2 else 'text'
140140

141-
doc_type_mapping = CarDocument._doc_type.mapping.to_dict()
142-
if ES_MAJOR_VERSION < 7:
143-
doc_type_mapping = doc_type_mapping['car_document']
141+
doc_type_mapping = CarDocument._doc_type.mapping.to_dict()['car_document']
144142

145143
self.assertDictEqual(
146144
doc_type_mapping, {
@@ -217,9 +215,8 @@ def test_model_instance_update(self):
217215
'color': doc.prepare_color(None),
218216
},
219217
'_index': 'car_index',
218+
'_type': 'car_document'
220219
}]
221-
if ES_MAJOR_VERSION < 7:
222-
actions[0]['_type'] = 'car_document'
223220

224221
self.assertEqual(1, mock.call_count)
225222
self.assertEqual(
@@ -249,6 +246,7 @@ def test_model_instance_iterable_update(self):
249246
'color': doc.prepare_color(None),
250247
},
251248
'_index': 'car_index',
249+
'_type': 'car_document'
252250
},
253251
{
254252
'_id': car2.pk,
@@ -259,11 +257,9 @@ def test_model_instance_iterable_update(self):
259257
'type': car2.type(),
260258
'color': doc.prepare_color(None),
261259
},
262-
'_index': 'car_index'
260+
'_index': 'car_index',
261+
'_type': 'car_document'
263262
}]
264-
if ES_MAJOR_VERSION < 7:
265-
actions[0]['_type'] = 'car_document'
266-
actions[1]['_type'] = 'car_document'
267263
self.assertEqual(1, mock.call_count)
268264
self.assertListEqual(
269265
actions, list(mock.call_args_list[0][1]['actions'])

tests/test_integration.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,10 @@ def test_index_to_dict(self):
207207
}
208208
})
209209

210-
index_dict_mappings = index_dict['mappings']
211-
if ES_MAJOR_VERSION < 7:
212-
index_dict_mappings = index_dict_mappings['doc']
210+
index_dict_mappings = index_dict['doc']
213211

214212
self.assertDictEqual(
215-
index_dict_mappings,
213+
index_dict_mappings,
216214
{
217215
'properties': {
218216
'ads': {
@@ -374,8 +372,8 @@ def test_default_document_id(self):
374372
slug=article_slug,
375373
)
376374

377-
# saving should create two documents (in the two indices): one with the
378-
# Django object's id as the ES doc _id, and the other with the slug
375+
# saving should create two documents (in the two indices): one with the
376+
# Django object's id as the ES doc _id, and the other with the slug
379377
# as the ES _id
380378
article.save()
381379

@@ -392,8 +390,8 @@ def test_custom_document_id(self):
392390
slug=article_slug,
393391
)
394392

395-
# saving should create two documents (in the two indices): one with the
396-
# Django object's id as the ES doc _id, and the other with the slug
393+
# saving should create two documents (in the two indices): one with the
394+
# Django object's id as the ES doc _id, and the other with the slug
397395
# as the ES _id
398396
article.save()
399397

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[tox]
22
envlist =
3-
py27-django-111-es{6,7}
4-
{py36,py37,py38}-django-{111,2,21,22,30}-es{6,7}
3+
{py27,py36,py37}-django-110-{es6}
4+
{py27,py36,py37}-django-111-{es6}
5+
{py36,py37}-django-2-{es6}
6+
{py36,py37}-django-21-{es6}
7+
{py36,py37}-django-22-{es6}
58

69
[testenv]
710
setenv =
@@ -14,13 +17,10 @@ deps =
1417
django-2: Django>=2.0,<2.1
1518
django-21: Django>=2.1,<2.2
1619
django-22: Django>=2.2,<2.3
17-
django-30: Django>=3.0,<3.1
1820
es6: elasticsearch-dsl>=6.4.0,<7.0.0
19-
es7: elasticsearch-dsl>=7,<8
2021
-r{toxinidir}/requirements_test.txt
2122

2223
basepython =
2324
py27: python2.7
2425
py36: python3.6
2526
py37: python3.7
26-
py38: python3.8

0 commit comments

Comments
 (0)