-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b5d3cb
commit d1292e1
Showing
9 changed files
with
146 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ selenium==2.53.6 | |
tox==3.1.2 | ||
#coreapi==2.3.3 | ||
#coreschema==0.0.4 | ||
mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/django_elasticsearch_dsl_drf/tests/test_versions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()]) | ||
) | ||
|
@@ -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: | ||
|
@@ -92,4 +114,3 @@ | |
pass | ||
|
||
del LooseVersion | ||
del get_elasticsearch_version |