Skip to content

Commit

Permalink
Merge pull request #10 from HBS-HBX/#9_type_error_DEMIndex_save
Browse files Browse the repository at this point in the history
closes #9 type error DEMIndex save
  • Loading branch information
codekiln authored Aug 3, 2018
2 parents 6775594 + 73639f7 commit 2e26553
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
---------

0.6.1 (2018-08-03)
~~~~~~~~~~~~~~~~~~
* fixed gh #9: "using elasticsearch-dsl 6.1, TypeError in DEMIndex.save"

0.6.0 (2018-08-01)
~~~~~~~~~~~~~~~~~~
* Added test structure for py2 - GH #2
Expand Down
2 changes: 1 addition & 1 deletion django_elastic_migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django_elastic_migrations.utils import loading
from django_elastic_migrations.utils.django_elastic_migrations_log import get_logger

__version__ = '0.6.0'
__version__ = '0.6.1'

default_app_config = 'django_elastic_migrations.apps.DjangoElasticMigrationsConfig' # pylint: disable=invalid-name

Expand Down
3 changes: 3 additions & 0 deletions django_elastic_migrations/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,9 @@ def save(self, using=None):
using = es_client
try:
super(DEMIndex, self).save(using=using)
except TypeError as te:
if "unexpected keyword argument 'using'" in str(te):
super(DEMIndex, self).save()
except ValueError as ex:
if "Empty value" in ex.message and not self.get_active_version_index_name():
msg = (
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def get_version(*file_paths):
license='MIT',
include_package_data=True,
install_requires=[
"Django>=1.8,<2.1", "elasticsearch-dsl>=6.0.0", "texttable>=1.2.1",
# TBD: GH issue #3 includes support for elasticsearch-dsl>=6.2.0
"Django>=1.8,<2.1", "elasticsearch-dsl>=6.0.0,<6.2.0", "texttable>=1.2.1",
"multiprocessing-logging>=0.2.6"
],
zip_safe=False,
Expand Down
16 changes: 16 additions & 0 deletions tests/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

from __future__ import (absolute_import, division, print_function, unicode_literals)

from elasticsearch import TransportError
from elasticsearch_dsl.exceptions import IllegalOperation

from django_elastic_migrations import DEMIndexManager
from django_elastic_migrations.utils.test_utils import DEMTestCase
from tests.es_config import ES_CLIENT
from tests.search import MovieSearchIndex, MovieSearchDoc
from tests.models import Movie

Expand All @@ -34,3 +38,15 @@ def test_update_index(self):
results = MovieSearchDoc.get_search(movie_title).execute()
first_result = results[0]
self.assertEqual(str(movie.id), first_result.meta.id)

def test_save_index_elasticsearch_dsl_lt_62(self):
"""
Added for #9 type error DEMIndex save
Tests that DEMIndex.save(using=using) works in 6.1 and 6.2 versions of DEM
"""
try:
# if elasticsearch_dsl <= 6.2, using is not a parameter but shouldn't throw exception
MovieSearchIndex.save(using=ES_CLIENT)
except (TransportError, IllegalOperation):
# the indexes already exist
pass

0 comments on commit 2e26553

Please sign in to comment.