Remove support for Python 2.x. (#548)
Signed-off-by: dblock <[email protected]>
This commit is contained in:
@@ -2,9 +2,6 @@ TEST_SUITE:
|
|||||||
- oss
|
- oss
|
||||||
|
|
||||||
PYTHON_VERSION:
|
PYTHON_VERSION:
|
||||||
- "2.7"
|
|
||||||
- "3.4"
|
|
||||||
- "3.5"
|
|
||||||
- "3.6"
|
- "3.6"
|
||||||
- "3.7"
|
- "3.7"
|
||||||
- "3.8"
|
- "3.8"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|||||||
### Deprecated
|
### Deprecated
|
||||||
- Deprecated point-in-time APIs (list_all_point_in_time, create_point_in_time, delete_point_in_time) and Security Client APIs (health_check and update_audit_config) ([#502](https://github.com/opensearch-project/opensearch-py/pull/502))
|
- Deprecated point-in-time APIs (list_all_point_in_time, create_point_in_time, delete_point_in_time) and Security Client APIs (health_check and update_audit_config) ([#502](https://github.com/opensearch-project/opensearch-py/pull/502))
|
||||||
### Removed
|
### Removed
|
||||||
|
- Removed leftover support for Python 2.7 ([#548](https://github.com/opensearch-project/opensearch-py/pull/548))
|
||||||
### Fixed
|
### Fixed
|
||||||
### Security
|
### Security
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|||||||
@@ -12,14 +12,13 @@ pytz
|
|||||||
numpy; python_version<"3.10"
|
numpy; python_version<"3.10"
|
||||||
pandas; python_version<"3.10"
|
pandas; python_version<"3.10"
|
||||||
|
|
||||||
pyyaml>=5.4; python_version>="3.6"
|
pyyaml>=5.4
|
||||||
pyyaml==5.3.1; python_version<"3.6"
|
|
||||||
|
|
||||||
isort
|
isort
|
||||||
black; python_version>="3.6"
|
black
|
||||||
twine
|
twine
|
||||||
|
|
||||||
# Requirements for testing [async] extra
|
# Requirements for testing [async] extra
|
||||||
aiohttp; python_version>="3.6"
|
aiohttp
|
||||||
pytest-asyncio<=0.21.1; python_version>="3.6"
|
pytest-asyncio<=0.21.1
|
||||||
unasync; python_version>="3.6"
|
unasync
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ SOURCE_FILES = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@nox.session(python=["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"])
|
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"])
|
||||||
def test(session):
|
def test(session):
|
||||||
session.install(".")
|
session.install(".")
|
||||||
session.install("-r", "dev-requirements.txt")
|
session.install("-r", "dev-requirements.txt")
|
||||||
|
|||||||
+11
-18
@@ -248,22 +248,15 @@ __all__ = [
|
|||||||
"tokenizer",
|
"tokenizer",
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
from ._async.client import AsyncOpenSearch
|
||||||
# Asyncio only supported on Python 3.6+
|
from ._async.http_aiohttp import AIOHttpConnection, AsyncConnection
|
||||||
if sys.version_info < (3, 6):
|
from ._async.transport import AsyncTransport
|
||||||
raise ImportError
|
from .connection import AsyncHttpConnection
|
||||||
|
|
||||||
from ._async.client import AsyncOpenSearch
|
__all__ += [
|
||||||
from ._async.http_aiohttp import AIOHttpConnection, AsyncConnection
|
"AIOHttpConnection",
|
||||||
from ._async.transport import AsyncTransport
|
"AsyncConnection",
|
||||||
from .connection import AsyncHttpConnection
|
"AsyncTransport",
|
||||||
|
"AsyncOpenSearch",
|
||||||
__all__ += [
|
"AsyncHttpConnection",
|
||||||
"AIOHttpConnection",
|
]
|
||||||
"AsyncConnection",
|
|
||||||
"AsyncTransport",
|
|
||||||
"AsyncOpenSearch",
|
|
||||||
"AsyncHttpConnection",
|
|
||||||
]
|
|
||||||
except (ImportError, SyntaxError):
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
import sys
|
import sys
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
|
from ._async.client import AsyncOpenSearch as AsyncOpenSearch
|
||||||
|
from ._async.http_aiohttp import AIOHttpConnection as AIOHttpConnection
|
||||||
|
from ._async.http_aiohttp import AsyncConnection as AsyncConnection
|
||||||
|
from ._async.transport import AsyncTransport as AsyncTransport
|
||||||
from .client import OpenSearch as OpenSearch
|
from .client import OpenSearch as OpenSearch
|
||||||
from .connection import AsyncHttpConnection as AsyncHttpConnection
|
from .connection import AsyncHttpConnection as AsyncHttpConnection
|
||||||
from .connection import Connection as Connection
|
from .connection import Connection as Connection
|
||||||
@@ -54,6 +58,8 @@ from .exceptions import SSLError as SSLError
|
|||||||
from .exceptions import TransportError as TransportError
|
from .exceptions import TransportError as TransportError
|
||||||
from .exceptions import UnknownDslObject as UnknownDslObject
|
from .exceptions import UnknownDslObject as UnknownDslObject
|
||||||
from .exceptions import ValidationException as ValidationException
|
from .exceptions import ValidationException as ValidationException
|
||||||
|
from .helpers import AWSV4SignerAsyncAuth as AWSV4SignerAsyncAuth
|
||||||
|
from .helpers import AWSV4SignerAuth as AWSV4SignerAuth
|
||||||
from .helpers.aggs import A as A
|
from .helpers.aggs import A as A
|
||||||
from .helpers.analysis import Analyzer, CharFilter, Normalizer, TokenFilter, Tokenizer
|
from .helpers.analysis import Analyzer, CharFilter, Normalizer, TokenFilter, Tokenizer
|
||||||
from .helpers.document import Document as Document
|
from .helpers.document import Document as Document
|
||||||
@@ -120,19 +126,6 @@ from .helpers.wrappers import Range as Range
|
|||||||
from .serializer import JSONSerializer as JSONSerializer
|
from .serializer import JSONSerializer as JSONSerializer
|
||||||
from .transport import Transport as Transport
|
from .transport import Transport as Transport
|
||||||
|
|
||||||
try:
|
|
||||||
if sys.version_info < (3, 6):
|
|
||||||
raise ImportError
|
|
||||||
|
|
||||||
from ._async.client import AsyncOpenSearch as AsyncOpenSearch
|
|
||||||
from ._async.http_aiohttp import AIOHttpConnection as AIOHttpConnection
|
|
||||||
from ._async.http_aiohttp import AsyncConnection as AsyncConnection
|
|
||||||
from ._async.transport import AsyncTransport as AsyncTransport
|
|
||||||
from .helpers import AWSV4SignerAsyncAuth as AWSV4SignerAsyncAuth
|
|
||||||
from .helpers import AWSV4SignerAuth as AWSV4SignerAuth
|
|
||||||
except (ImportError, SyntaxError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
VERSION: Tuple[int, int, int]
|
VERSION: Tuple[int, int, int]
|
||||||
__version__: Tuple[int, int, int]
|
__version__: Tuple[int, int, int]
|
||||||
__versionstr__: str
|
__versionstr__: str
|
||||||
|
|||||||
@@ -25,9 +25,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from .base import Connection
|
from .base import Connection
|
||||||
|
from .http_async import AsyncHttpConnection
|
||||||
from .http_requests import RequestsHttpConnection
|
from .http_requests import RequestsHttpConnection
|
||||||
from .http_urllib3 import Urllib3HttpConnection, create_ssl_context
|
from .http_urllib3 import Urllib3HttpConnection, create_ssl_context
|
||||||
|
|
||||||
@@ -36,17 +35,5 @@ __all__ = [
|
|||||||
"RequestsHttpConnection",
|
"RequestsHttpConnection",
|
||||||
"Urllib3HttpConnection",
|
"Urllib3HttpConnection",
|
||||||
"create_ssl_context",
|
"create_ssl_context",
|
||||||
|
"AsyncHttpConnection",
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
|
||||||
# Asyncio only supported on Python 3.6+
|
|
||||||
if sys.version_info < (3, 6):
|
|
||||||
raise ImportError
|
|
||||||
|
|
||||||
from .http_async import AsyncHttpConnection
|
|
||||||
|
|
||||||
__all__ += [
|
|
||||||
"AsyncHttpConnection",
|
|
||||||
]
|
|
||||||
except (ImportError, SyntaxError):
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -25,8 +25,12 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import sys
|
from .._async.helpers.actions import (
|
||||||
|
async_bulk,
|
||||||
|
async_reindex,
|
||||||
|
async_scan,
|
||||||
|
async_streaming_bulk,
|
||||||
|
)
|
||||||
from .actions import (
|
from .actions import (
|
||||||
_chunk_actions,
|
_chunk_actions,
|
||||||
_process_bulk_chunk,
|
_process_bulk_chunk,
|
||||||
@@ -56,16 +60,8 @@ __all__ = [
|
|||||||
"AWSV4SignerAsyncAuth",
|
"AWSV4SignerAsyncAuth",
|
||||||
"RequestsAWSV4SignerAuth",
|
"RequestsAWSV4SignerAuth",
|
||||||
"Urllib3AWSV4SignerAuth",
|
"Urllib3AWSV4SignerAuth",
|
||||||
|
"async_scan",
|
||||||
|
"async_bulk",
|
||||||
|
"async_reindex",
|
||||||
|
"async_streaming_bulk",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Asyncio only supported on Python 3.6+
|
|
||||||
if sys.version_info >= (3, 6):
|
|
||||||
from .._async.helpers.actions import (
|
|
||||||
async_bulk,
|
|
||||||
async_reindex,
|
|
||||||
async_scan,
|
|
||||||
async_streaming_bulk,
|
|
||||||
)
|
|
||||||
|
|
||||||
__all__ += ["async_scan", "async_bulk", "async_reindex", "async_streaming_bulk"]
|
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from .._async.helpers.actions import async_bulk as async_bulk
|
||||||
|
from .._async.helpers.actions import async_reindex as async_reindex
|
||||||
|
from .._async.helpers.actions import async_scan as async_scan
|
||||||
|
from .._async.helpers.actions import async_streaming_bulk as async_streaming_bulk
|
||||||
from .actions import _chunk_actions as _chunk_actions
|
from .actions import _chunk_actions as _chunk_actions
|
||||||
from .actions import _process_bulk_chunk as _process_bulk_chunk
|
from .actions import _process_bulk_chunk as _process_bulk_chunk
|
||||||
from .actions import bulk as bulk
|
from .actions import bulk as bulk
|
||||||
@@ -34,20 +38,8 @@ from .actions import parallel_bulk as parallel_bulk
|
|||||||
from .actions import reindex as reindex
|
from .actions import reindex as reindex
|
||||||
from .actions import scan as scan
|
from .actions import scan as scan
|
||||||
from .actions import streaming_bulk as streaming_bulk
|
from .actions import streaming_bulk as streaming_bulk
|
||||||
|
from .asyncsigner import AWSV4SignerAsyncAuth as AWSV4SignerAsyncAuth
|
||||||
from .errors import BulkIndexError as BulkIndexError
|
from .errors import BulkIndexError as BulkIndexError
|
||||||
from .errors import ScanError as ScanError
|
from .errors import ScanError as ScanError
|
||||||
|
from .signer import AWSV4SignerAuth as AWSV4SignerAuth
|
||||||
try:
|
from .signer import RequestsAWSV4SignerAuth, Urllib3AWSV4SignerAuth
|
||||||
# Asyncio only supported on Python 3.6+
|
|
||||||
if sys.version_info < (3, 6):
|
|
||||||
raise ImportError
|
|
||||||
|
|
||||||
from .._async.helpers.actions import async_bulk as async_bulk
|
|
||||||
from .._async.helpers.actions import async_reindex as async_reindex
|
|
||||||
from .._async.helpers.actions import async_scan as async_scan
|
|
||||||
from .._async.helpers.actions import async_streaming_bulk as async_streaming_bulk
|
|
||||||
from .asyncsigner import AWSV4SignerAsyncAuth as AWSV4SignerAsyncAuth
|
|
||||||
from .signer import AWSV4SignerAuth as AWSV4SignerAuth
|
|
||||||
from .signer import RequestsAWSV4SignerAuth, Urllib3AWSV4SignerAuth
|
|
||||||
except (ImportError, SyntaxError):
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from os.path import abspath, dirname, join
|
from os.path import abspath, dirname, join
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
@@ -54,8 +53,7 @@ install_requires = [
|
|||||||
"requests>=2.4.0, <3.0.0",
|
"requests>=2.4.0, <3.0.0",
|
||||||
"six",
|
"six",
|
||||||
"python-dateutil",
|
"python-dateutil",
|
||||||
# ipaddress is included in stdlib since python 3.3
|
"certifi>=2022.12.07",
|
||||||
'ipaddress; python_version<"3.3"',
|
|
||||||
]
|
]
|
||||||
tests_require = [
|
tests_require = [
|
||||||
"requests>=2.0.0, <3.0.0",
|
"requests>=2.0.0, <3.0.0",
|
||||||
@@ -65,11 +63,9 @@ tests_require = [
|
|||||||
"pytest>=3.0.0",
|
"pytest>=3.0.0",
|
||||||
"pytest-cov",
|
"pytest-cov",
|
||||||
"pytz",
|
"pytz",
|
||||||
"botocore;python_version>='3.6'",
|
"botocore",
|
||||||
|
"pytest-mock<4.0.0",
|
||||||
]
|
]
|
||||||
if sys.version_info >= (3, 6):
|
|
||||||
tests_require.append("pytest-mock<4.0.0")
|
|
||||||
install_requires.append("certifi>=2022.12.07")
|
|
||||||
|
|
||||||
async_require = ["aiohttp>=3,<4"]
|
async_require = ["aiohttp>=3,<4"]
|
||||||
|
|
||||||
@@ -103,11 +99,6 @@ setup(
|
|||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
"Programming Language :: Python :: 2",
|
|
||||||
"Programming Language :: Python :: 2.7",
|
|
||||||
"Programming Language :: Python :: 3",
|
|
||||||
"Programming Language :: Python :: 3.4",
|
|
||||||
"Programming Language :: Python :: 3.5",
|
|
||||||
"Programming Language :: Python :: 3.6",
|
"Programming Language :: Python :: 3.6",
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.7",
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
|
|||||||
@@ -116,27 +116,19 @@ def run_all(argv=None):
|
|||||||
if test_pattern:
|
if test_pattern:
|
||||||
argv.append("-k %s" % test_pattern)
|
argv.append("-k %s" % test_pattern)
|
||||||
else:
|
else:
|
||||||
ignores = []
|
ignores = [
|
||||||
# Python 3.6+ is required for async
|
"test_opensearchpy/test_server/",
|
||||||
if sys.version_info < (3, 6):
|
"test_opensearchpy/test_server_secured/",
|
||||||
ignores.append("test_opensearchpy/test_async/")
|
"test_opensearchpy/test_async/test_server/",
|
||||||
|
"test_opensearchpy/test_async/test_server_secured/",
|
||||||
ignores.extend(
|
]
|
||||||
[
|
|
||||||
"test_opensearchpy/test_server/",
|
|
||||||
"test_opensearchpy/test_server_secured/",
|
|
||||||
"test_opensearchpy/test_async/test_server/",
|
|
||||||
"test_opensearchpy/test_async/test_server_secured/",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Jenkins/Github actions, only run server tests
|
# Jenkins/Github actions, only run server tests
|
||||||
if environ.get("TEST_TYPE") == "server":
|
if environ.get("TEST_TYPE") == "server":
|
||||||
test_dir = abspath(dirname(__file__))
|
test_dir = abspath(dirname(__file__))
|
||||||
if secured:
|
if secured:
|
||||||
argv.append(join(test_dir, "test_server_secured"))
|
argv.append(join(test_dir, "test_server_secured"))
|
||||||
if sys.version_info >= (3, 6):
|
argv.append(join(test_dir, "test_async/test_server_secured"))
|
||||||
argv.append(join(test_dir, "test_async/test_server_secured"))
|
|
||||||
ignores.extend(
|
ignores.extend(
|
||||||
[
|
[
|
||||||
"test_opensearchpy/test_server/",
|
"test_opensearchpy/test_server/",
|
||||||
@@ -145,8 +137,7 @@ def run_all(argv=None):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
argv.append(join(test_dir, "test_server"))
|
argv.append(join(test_dir, "test_server"))
|
||||||
if sys.version_info >= (3, 6):
|
argv.append(join(test_dir, "test_async/test_server"))
|
||||||
argv.append(join(test_dir, "test_async/test_server"))
|
|
||||||
ignores.extend(
|
ignores.extend(
|
||||||
[
|
[
|
||||||
"test_opensearchpy/test_server_secured/",
|
"test_opensearchpy/test_server_secured/",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
# Modifications Copyright OpenSearch Contributors. See
|
# Modifications Copyright OpenSearch Contributors. See
|
||||||
# GitHub history for details.
|
# GitHub history for details.
|
||||||
|
|
||||||
import sys
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -42,9 +41,6 @@ class TestAsyncSigner:
|
|||||||
assert "X-Amz-Date" in headers
|
assert "X-Amz-Date" in headers
|
||||||
assert "X-Amz-Security-Token" in headers
|
assert "X-Amz-Security-Token" in headers
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
async def test_aws_signer_async_when_region_is_null(self):
|
async def test_aws_signer_async_when_region_is_null(self):
|
||||||
session = self.mock_session()
|
session = self.mock_session()
|
||||||
|
|
||||||
@@ -58,9 +54,6 @@ class TestAsyncSigner:
|
|||||||
AWSV4SignerAsyncAuth(session, "")
|
AWSV4SignerAsyncAuth(session, "")
|
||||||
assert str(e.value) == "Region cannot be empty"
|
assert str(e.value) == "Region cannot be empty"
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
async def test_aws_signer_async_when_credentials_is_null(self):
|
async def test_aws_signer_async_when_credentials_is_null(self):
|
||||||
region = "us-west-1"
|
region = "us-west-1"
|
||||||
|
|
||||||
@@ -70,9 +63,6 @@ class TestAsyncSigner:
|
|||||||
AWSV4SignerAsyncAuth(None, region)
|
AWSV4SignerAsyncAuth(None, region)
|
||||||
assert str(e.value) == "Credentials cannot be empty"
|
assert str(e.value) == "Credentials cannot be empty"
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="AWSV4SignerAsyncAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
async def test_aws_signer_async_when_service_is_specified(self):
|
async def test_aws_signer_async_when_service_is_specified(self):
|
||||||
region = "us-west-2"
|
region = "us-west-2"
|
||||||
service = "aoss"
|
service = "aoss"
|
||||||
@@ -100,9 +90,6 @@ class TestAsyncSignerWithFrozenCredentials(TestAsyncSigner):
|
|||||||
|
|
||||||
return dummy_session
|
return dummy_session
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="AWSV4SignerAsyncAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
async def test_aws_signer_async_frozen_credentials_as_http_auth(self):
|
async def test_aws_signer_async_frozen_credentials_as_http_auth(self):
|
||||||
region = "us-west-2"
|
region = "us-west-2"
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import uuid
|
import uuid
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@@ -36,7 +35,6 @@ import pytest
|
|||||||
from mock import Mock, patch
|
from mock import Mock, patch
|
||||||
from requests.auth import AuthBase
|
from requests.auth import AuthBase
|
||||||
|
|
||||||
from opensearchpy.compat import reraise_exceptions
|
|
||||||
from opensearchpy.connection import Connection, RequestsHttpConnection
|
from opensearchpy.connection import Connection, RequestsHttpConnection
|
||||||
from opensearchpy.exceptions import (
|
from opensearchpy.exceptions import (
|
||||||
ConflictError,
|
ConflictError,
|
||||||
@@ -44,12 +42,10 @@ from opensearchpy.exceptions import (
|
|||||||
RequestError,
|
RequestError,
|
||||||
TransportError,
|
TransportError,
|
||||||
)
|
)
|
||||||
|
from test_opensearchpy.TestHttpServer import TestHTTPServer
|
||||||
|
|
||||||
from ..test_cases import TestCase
|
from ..test_cases import TestCase
|
||||||
|
|
||||||
if sys.version_info > (3, 0):
|
|
||||||
from test_opensearchpy.TestHttpServer import TestHTTPServer
|
|
||||||
|
|
||||||
|
|
||||||
class TestRequestsHttpConnection(TestCase):
|
class TestRequestsHttpConnection(TestCase):
|
||||||
def _get_mock_connection(
|
def _get_mock_connection(
|
||||||
@@ -393,9 +389,6 @@ class TestRequestsHttpConnection(TestCase):
|
|||||||
status, headers, data = con.perform_request("GET", "/")
|
status, headers, data = con.perform_request("GET", "/")
|
||||||
self.assertEqual(u"你好\uda6a", data) # fmt: skip
|
self.assertEqual(u"你好\uda6a", data) # fmt: skip
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
not reraise_exceptions, reason="RecursionError isn't defined in Python <3.5"
|
|
||||||
)
|
|
||||||
def test_recursion_error_reraised(self):
|
def test_recursion_error_reraised(self):
|
||||||
conn = RequestsHttpConnection()
|
conn = RequestsHttpConnection()
|
||||||
|
|
||||||
@@ -420,9 +413,6 @@ class TestRequestsHttpConnection(TestCase):
|
|||||||
|
|
||||||
return dummy_session
|
return dummy_session
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="RequestsAWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_aws_signer_as_http_auth(self):
|
def test_aws_signer_as_http_auth(self):
|
||||||
region = "us-west-2"
|
region = "us-west-2"
|
||||||
|
|
||||||
@@ -440,9 +430,6 @@ class TestRequestsHttpConnection(TestCase):
|
|||||||
self.assertIn("X-Amz-Security-Token", prepared_request.headers)
|
self.assertIn("X-Amz-Security-Token", prepared_request.headers)
|
||||||
self.assertIn("X-Amz-Content-SHA256", prepared_request.headers)
|
self.assertIn("X-Amz-Content-SHA256", prepared_request.headers)
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="RequestsAWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_aws_signer_when_service_is_specified(self):
|
def test_aws_signer_when_service_is_specified(self):
|
||||||
region = "us-west-1"
|
region = "us-west-1"
|
||||||
service = "aoss"
|
service = "aoss"
|
||||||
@@ -460,9 +447,6 @@ class TestRequestsHttpConnection(TestCase):
|
|||||||
self.assertIn("X-Amz-Date", prepared_request.headers)
|
self.assertIn("X-Amz-Date", prepared_request.headers)
|
||||||
self.assertIn("X-Amz-Security-Token", prepared_request.headers)
|
self.assertIn("X-Amz-Security-Token", prepared_request.headers)
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="RequestsAWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
@patch("opensearchpy.helpers.signer.AWSV4Signer.sign")
|
@patch("opensearchpy.helpers.signer.AWSV4Signer.sign")
|
||||||
def test_aws_signer_signs_with_query_string(self, mock_sign):
|
def test_aws_signer_signs_with_query_string(self, mock_sign):
|
||||||
region = "us-west-1"
|
region = "us-west-1"
|
||||||
@@ -484,10 +468,6 @@ class TestRequestsHttpConnection(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 0),
|
|
||||||
reason="http_server is only available from python 3.x",
|
|
||||||
)
|
|
||||||
class TestRequestsConnectionRedirect:
|
class TestRequestsConnectionRedirect:
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_class(cls):
|
def setup_class(cls):
|
||||||
@@ -537,9 +517,6 @@ class TestSignerWithFrozenCredentials(TestRequestsHttpConnection):
|
|||||||
|
|
||||||
return dummy_session
|
return dummy_session
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="RequestsAWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_requests_http_connection_aws_signer_frozen_credentials_as_http_auth(self):
|
def test_requests_http_connection_aws_signer_frozen_credentials_as_http_auth(self):
|
||||||
region = "us-west-2"
|
region = "us-west-2"
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
|
||||||
import uuid
|
import uuid
|
||||||
import warnings
|
import warnings
|
||||||
from gzip import GzipFile
|
from gzip import GzipFile
|
||||||
@@ -40,7 +39,6 @@ from mock import Mock, patch
|
|||||||
from urllib3._collections import HTTPHeaderDict
|
from urllib3._collections import HTTPHeaderDict
|
||||||
|
|
||||||
from opensearchpy import __versionstr__
|
from opensearchpy import __versionstr__
|
||||||
from opensearchpy.compat import reraise_exceptions
|
|
||||||
from opensearchpy.connection import Connection, Urllib3HttpConnection
|
from opensearchpy.connection import Connection, Urllib3HttpConnection
|
||||||
|
|
||||||
from ..test_cases import SkipTest, TestCase
|
from ..test_cases import SkipTest, TestCase
|
||||||
@@ -179,9 +177,6 @@ class TestUrllib3HttpConnection(TestCase):
|
|||||||
con.headers,
|
con.headers,
|
||||||
)
|
)
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="Urllib3AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
@patch(
|
@patch(
|
||||||
"urllib3.HTTPConnectionPool.urlopen",
|
"urllib3.HTTPConnectionPool.urlopen",
|
||||||
return_value=Mock(status=200, headers=HTTPHeaderDict({}), data=b"{}"),
|
return_value=Mock(status=200, headers=HTTPHeaderDict({}), data=b"{}"),
|
||||||
@@ -202,9 +197,6 @@ class TestUrllib3HttpConnection(TestCase):
|
|||||||
self.assertIn("X-Amz-Security-Token", headers)
|
self.assertIn("X-Amz-Security-Token", headers)
|
||||||
self.assertIn("X-Amz-Content-SHA256", headers)
|
self.assertIn("X-Amz-Content-SHA256", headers)
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="Urllib3AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_aws_signer_as_http_auth(self):
|
def test_aws_signer_as_http_auth(self):
|
||||||
region = "us-west-2"
|
region = "us-west-2"
|
||||||
|
|
||||||
@@ -217,9 +209,6 @@ class TestUrllib3HttpConnection(TestCase):
|
|||||||
self.assertIn("X-Amz-Security-Token", headers)
|
self.assertIn("X-Amz-Security-Token", headers)
|
||||||
self.assertIn("X-Amz-Content-SHA256", headers)
|
self.assertIn("X-Amz-Content-SHA256", headers)
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="Urllib3AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_aws_signer_when_region_is_null(self):
|
def test_aws_signer_when_region_is_null(self):
|
||||||
session = self.mock_session()
|
session = self.mock_session()
|
||||||
|
|
||||||
@@ -233,9 +222,6 @@ class TestUrllib3HttpConnection(TestCase):
|
|||||||
Urllib3AWSV4SignerAuth(session, "")
|
Urllib3AWSV4SignerAuth(session, "")
|
||||||
assert str(e.value) == "Region cannot be empty"
|
assert str(e.value) == "Region cannot be empty"
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="Urllib3AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_aws_signer_when_credentials_is_null(self):
|
def test_aws_signer_when_credentials_is_null(self):
|
||||||
region = "us-west-1"
|
region = "us-west-1"
|
||||||
|
|
||||||
@@ -249,9 +235,6 @@ class TestUrllib3HttpConnection(TestCase):
|
|||||||
Urllib3AWSV4SignerAuth("", region)
|
Urllib3AWSV4SignerAuth("", region)
|
||||||
assert str(e.value) == "Credentials cannot be empty"
|
assert str(e.value) == "Credentials cannot be empty"
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="Urllib3AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_aws_signer_when_service_is_specified(self):
|
def test_aws_signer_when_service_is_specified(self):
|
||||||
region = "us-west-1"
|
region = "us-west-1"
|
||||||
service = "aoss"
|
service = "aoss"
|
||||||
@@ -358,9 +341,6 @@ class TestUrllib3HttpConnection(TestCase):
|
|||||||
status, headers, data = con.perform_request("GET", "/")
|
status, headers, data = con.perform_request("GET", "/")
|
||||||
self.assertEqual(u"你好\uda6a", data) # fmt: skip
|
self.assertEqual(u"你好\uda6a", data) # fmt: skip
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
not reraise_exceptions, reason="RecursionError isn't defined in Python <3.5"
|
|
||||||
)
|
|
||||||
def test_recursion_error_reraised(self):
|
def test_recursion_error_reraised(self):
|
||||||
conn = Urllib3HttpConnection()
|
conn = Urllib3HttpConnection()
|
||||||
|
|
||||||
@@ -387,9 +367,6 @@ class TestSignerWithFrozenCredentials(TestUrllib3HttpConnection):
|
|||||||
|
|
||||||
return dummy_session
|
return dummy_session
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
sys.version_info < (3, 6), reason="Urllib3AWSV4SignerAuth requires python3.6+"
|
|
||||||
)
|
|
||||||
def test_urllib3_http_connection_aws_signer_frozen_credentials_as_http_auth(self):
|
def test_urllib3_http_connection_aws_signer_frozen_credentials_as_http_auth(self):
|
||||||
region = "us-west-2"
|
region = "us-west-2"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import sys
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
|
|
||||||
@@ -150,7 +149,6 @@ def test_scaled_float():
|
|||||||
assert f.to_dict() == {"scaling_factor": 123, "type": "scaled_float"}
|
assert f.to_dict() == {"scaling_factor": 123, "type": "scaled_float"}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6 or higher")
|
|
||||||
def test_ipaddress():
|
def test_ipaddress():
|
||||||
f = field.Ip()
|
f = field.Ip()
|
||||||
assert f.deserialize("127.0.0.1") == ip_address("127.0.0.1")
|
assert f.deserialize("127.0.0.1") == ip_address("127.0.0.1")
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ clients.
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import warnings
|
import warnings
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
@@ -135,8 +134,7 @@ SKIP_TESTS = {
|
|||||||
|
|
||||||
OPENSEARCH_VERSION = None
|
OPENSEARCH_VERSION = None
|
||||||
RUN_ASYNC_REST_API_TESTS = (
|
RUN_ASYNC_REST_API_TESTS = (
|
||||||
sys.version_info >= (3, 6)
|
os.environ.get("PYTHON_CONNECTION_CLASS") == "RequestsHttpConnection"
|
||||||
and os.environ.get("PYTHON_CONNECTION_CLASS") == "RequestsHttpConnection"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
FALSEY_VALUES = ("", None, False, 0, 0.0)
|
FALSEY_VALUES = ("", None, False, 0, 0.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user