Skip to content

Commit

Permalink
prepare 0.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Sep 20, 2019
1 parent 2b5d3cb commit d1292e1
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.20.3
------
2019-09-20

- Testing the auxiliary versions module.

0.20.2
------
2019-08-30
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.20.2
------
2019-09-20

- Testing the auxiliary versions module.

0.20.2
------
2019-08-30
Expand Down
1 change: 1 addition & 0 deletions examples/requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ selenium==2.53.6
tox==3.1.2
#coreapi==2.3.3
#coreschema==0.0.4
mock
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import find_packages, setup

version = '0.20.2'
version = '0.20.3'

DOCS_TRANSFORMATIONS = (
(
Expand Down Expand Up @@ -173,6 +173,7 @@
'pytest-django',
'pytest-cov',
'tox',
'mock',
]

setup(
Expand Down
2 changes: 1 addition & 1 deletion src/django_elasticsearch_dsl_drf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

__title__ = 'django-elasticsearch-dsl-drf'
__version__ = '0.20.2'
__version__ = '0.20.3'
__author__ = 'Artur Barseghyan <[email protected]>'
__copyright__ = '2017-2019 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
Expand Down
20 changes: 3 additions & 17 deletions src/django_elasticsearch_dsl_drf/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

from django_elasticsearch_dsl import fields

# For compatibility reasons
from .versions import get_elasticsearch_version

try:
import coreapi
except ImportError:
Expand All @@ -30,7 +33,6 @@
'coreapi',
'coreschema',
# 'get_count',
'get_elasticsearch_version',
'KeywordField',
'StringField',
)
Expand All @@ -49,22 +51,6 @@
# return _get_count(queryset)


def get_elasticsearch_version(default=(2, 0, 0)):
"""Get Elasticsearch version.
:param default: Default value. Mainly added for building the docs
when Elasticsearch is not running.
:type default: tuple
:return:
:rtype: list
"""
try:
from elasticsearch_dsl import __version__
return __version__
except ImportError:
return default


def keyword_field(**kwargs):
"""Keyword field.
Expand Down
4 changes: 2 additions & 2 deletions src/django_elasticsearch_dsl_drf/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ def _test_search_any_word_in_indexed_fields(self,
title_match=None,
create_factory=False):
if create_factory:
book = factories.BookWithUniqueTitleFactory(
factories.BookWithUniqueTitleFactory(
title='This is a short indexed description'
)
other_books = factories.BookWithUniqueTitleFactory.create_batch(100)
factories.BookWithUniqueTitleFactory.create_batch(100)
self._reindex()

self.authenticate()
Expand Down
101 changes: 101 additions & 0 deletions src/django_elasticsearch_dsl_drf/tests/test_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import unittest
import mock
# For Python3 >= 3.4
try:
from importlib import reload
# For Python3 < 3.4
except ImportError as err:
try:
from imp import reload
except ImportError as err:
pass

__title__ = 'django_elasticsearch_dsl_drf.tests.test_versions'
__author__ = 'Artur Barseghyan'
__copyright__ = 'Copyright (c) 2017-2019 Artur Barseghyan'
__license__ = 'GPL-2.0-only OR LGPL-2.1-or-later'
__all__ = ('VersionsTest',)


class VersionsTest(unittest.TestCase):
"""
Tests of ``django_elasticsearch_dsl_drf.versions`` module.
"""
def setUp(self):
pass

@mock.patch('elasticsearch_dsl.__version__', [6, 3, 0])
def test_elasticsearch_dsl_6_3_0(self):
"""
Tests as if we were using elasticsearch_dsl==6.3.0.
"""
from django_elasticsearch_dsl_drf import versions
reload(versions)

# Exact version matching
self.assertFalse(versions.ELASTICSEARCH_7_0)
self.assertTrue(versions.ELASTICSEARCH_6_3)
self.assertFalse(versions.ELASTICSEARCH_6_2)
self.assertFalse(versions.ELASTICSEARCH_5_4)
self.assertFalse(versions.ELASTICSEARCH_2_0)
self.assertFalse(versions.ELASTICSEARCH_6_2)

# Less than or equal matching
self.assertFalse(versions.ELASTICSEARCH_LTE_2_0)
self.assertFalse(versions.ELASTICSEARCH_LTE_2_2)
self.assertFalse(versions.ELASTICSEARCH_LTE_5_0)
self.assertFalse(versions.ELASTICSEARCH_LTE_5_3)
self.assertFalse(versions.ELASTICSEARCH_LTE_6_0)
self.assertTrue(versions.ELASTICSEARCH_LTE_6_3)
self.assertTrue(versions.ELASTICSEARCH_LTE_7_0)
self.assertTrue(versions.ELASTICSEARCH_LTE_8_0)

# Greater than or equal matching
self.assertTrue(versions.ELASTICSEARCH_GTE_2_0)
self.assertTrue(versions.ELASTICSEARCH_GTE_2_2)
self.assertTrue(versions.ELASTICSEARCH_GTE_5_0)
self.assertTrue(versions.ELASTICSEARCH_GTE_5_3)
self.assertTrue(versions.ELASTICSEARCH_GTE_6_0)
self.assertTrue(versions.ELASTICSEARCH_GTE_6_3)
self.assertFalse(versions.ELASTICSEARCH_GTE_7_0)
self.assertFalse(versions.ELASTICSEARCH_GTE_8_0)

@mock.patch('elasticsearch_dsl.__version__', [7, 0, 0])
def test_elasticsearch_dsl_7_0_0(self):
"""
Tests as if we were using elasticsearch_dsl==7.0.0.
"""
from django_elasticsearch_dsl_drf import versions
reload(versions)

# Exact version matching
self.assertTrue(versions.ELASTICSEARCH_7_0)
self.assertFalse(versions.ELASTICSEARCH_6_3)
self.assertFalse(versions.ELASTICSEARCH_6_2)
self.assertFalse(versions.ELASTICSEARCH_5_4)
self.assertFalse(versions.ELASTICSEARCH_2_0)
self.assertFalse(versions.ELASTICSEARCH_6_2)

# Less than or equal matching
self.assertFalse(versions.ELASTICSEARCH_LTE_2_0)
self.assertFalse(versions.ELASTICSEARCH_LTE_2_2)
self.assertFalse(versions.ELASTICSEARCH_LTE_5_0)
self.assertFalse(versions.ELASTICSEARCH_LTE_5_3)
self.assertFalse(versions.ELASTICSEARCH_LTE_6_0)
self.assertFalse(versions.ELASTICSEARCH_LTE_6_3)
self.assertTrue(versions.ELASTICSEARCH_LTE_7_0)
self.assertTrue(versions.ELASTICSEARCH_LTE_8_0)

# Greater than or equal matching
self.assertTrue(versions.ELASTICSEARCH_GTE_2_0)
self.assertTrue(versions.ELASTICSEARCH_GTE_2_2)
self.assertTrue(versions.ELASTICSEARCH_GTE_5_0)
self.assertTrue(versions.ELASTICSEARCH_GTE_5_3)
self.assertTrue(versions.ELASTICSEARCH_GTE_6_0)
self.assertTrue(versions.ELASTICSEARCH_GTE_6_3)
self.assertTrue(versions.ELASTICSEARCH_GTE_7_0)
self.assertFalse(versions.ELASTICSEARCH_GTE_8_0)


if __name__ == "__main__":
unittest.main()
27 changes: 24 additions & 3 deletions src/django_elasticsearch_dsl_drf/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,33 @@

from distutils.version import LooseVersion

from .compat import get_elasticsearch_version

__title__ = 'django_elasticsearch_dsl_drf.versions'
__author__ = 'Artur Barseghyan <[email protected]>'
__copyright__ = '2017-2019 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = [
'get_elasticsearch_version',
'LOOSE_ELASTICSEARCH_VERSION',
'LOOSE_ELASTICSEARCH_MINOR_VERSION',
]


def get_elasticsearch_version(default=(2, 0, 0)):
"""Get Elasticsearch version.
:param default: Default value. Mainly added for building the docs
when Elasticsearch is not running.
:type default: tuple
:return:
:rtype: list
"""
try:
from elasticsearch_dsl import __version__
return __version__
except ImportError:
return default


LOOSE_ELASTICSEARCH_VERSION = LooseVersion(
'.'.join([str(__n) for __n in get_elasticsearch_version()])
)
Expand All @@ -36,8 +52,14 @@
'6.0',
'6.1',
'6.2',
'6.3',
'7.0',
'7.1',
'7.2',
'7.3',
'7.4',
'8.0',
'9.0',
)

for __v in LOOSE_VERSIONS:
Expand Down Expand Up @@ -92,4 +114,3 @@
pass

del LooseVersion
del get_elasticsearch_version

0 comments on commit d1292e1

Please sign in to comment.