Upgrade to aiohttp 3.10.6. (#829)

Signed-off-by: dblock <dblock@amazon.com>
This commit is contained in:
Daniel (dB.) Doubrovkine
2024-09-26 19:52:19 +02:00
committed by GitHub
parent 3087686fff
commit 0ccd4173cc
3 changed files with 32 additions and 16 deletions
+6
View File
@@ -45,6 +45,12 @@ docker run -d -p 9200:9200 -p 9600:9600 -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=myS
Tests require a live instance of OpenSearch running in docker.
Set the password for your docker instance.
```
export OPENSEARCH_PASSWORD=myStrongPassword123!
```
If you have one running.
```
+1 -1
View File
@@ -20,6 +20,6 @@ black>=24.3.0
twine
# Requirements for testing [async] extra
aiohttp>=3.9.4, <=3.10.5
aiohttp>=3.9.4, <4
pytest-asyncio<=0.24.0
unasync
@@ -37,6 +37,27 @@ from opensearchpy.connection.http_async import AsyncHttpConnection
class TestAsyncHttpConnection:
class MockResponse:
def __init__(
self,
text: Any = None,
status: int = 200,
headers: Any = CIMultiDict(),
) -> None:
self._text = text
self.status = status
self.headers = headers
async def text(self) -> Any:
return self._text
async def __aexit__(self, *args: Any) -> None:
pass
async def __aenter__(self) -> Any:
return self
def test_auth_as_tuple(self) -> None:
c = AsyncHttpConnection(http_auth=("username", "password"))
assert isinstance(c._http_auth, aiohttp.BasicAuth)
@@ -57,15 +78,10 @@ class TestAsyncHttpConnection:
assert callable(c._http_auth)
@pytest.mark.asyncio # type: ignore
@mock.patch("aiohttp.ClientSession.request", new_callable=mock.Mock)
@mock.patch("aiohttp.ClientSession.request")
async def test_basicauth_in_request_session(self, mock_request: Any) -> None:
async def do_request(*args: Any, **kwargs: Any) -> Any:
response_mock = mock.AsyncMock()
response_mock.headers = CIMultiDict()
response_mock.status = 200
return response_mock
mock_request.return_value = aiohttp.client._RequestContextManager(do_request())
mock_request.return_value = TestAsyncHttpConnection.MockResponse()
c = AsyncHttpConnection(
http_auth=("username", "password"),
@@ -89,20 +105,14 @@ class TestAsyncHttpConnection:
)
@pytest.mark.asyncio # type: ignore
@mock.patch("aiohttp.ClientSession.request", new_callable=mock.Mock)
@mock.patch("aiohttp.ClientSession.request")
async def test_callable_in_request_session(self, mock_request: Any) -> None:
def auth_fn(*args: Any, **kwargs: Any) -> Any:
return {
"Test": "PASSED",
}
async def do_request(*args: Any, **kwargs: Any) -> Any:
response_mock = mock.AsyncMock()
response_mock.headers = CIMultiDict()
response_mock.status = 200
return response_mock
mock_request.return_value = aiohttp.client._RequestContextManager(do_request())
mock_request.return_value = TestAsyncHttpConnection.MockResponse()
c = AsyncHttpConnection(http_auth=auth_fn, loop=get_running_loop())
c.headers = {}