|
29 | 29 | from mock import patch
|
30 | 30 | from multidict import CIMultiDict
|
31 | 31 |
|
| 32 | +import elasticsearch._async.http_aiohttp |
32 | 33 | from elasticsearch import AIOHttpConnection, AsyncElasticsearch, __versionstr__
|
33 | 34 | from elasticsearch.compat import reraise_exceptions
|
34 | 35 | from elasticsearch.exceptions import ConnectionError, NotFoundError
|
@@ -56,6 +57,9 @@ async def __aenter__(self, *_, **__):
|
56 | 57 | async def __aexit__(self, *_, **__):
|
57 | 58 | pass
|
58 | 59 |
|
| 60 | + async def release(self): |
| 61 | + pass |
| 62 | + |
59 | 63 | async def text(self):
|
60 | 64 | return response_body.decode("utf-8", "surrogatepass")
|
61 | 65 |
|
@@ -421,6 +425,21 @@ def request_raise(*_, **__):
|
421 | 425 | await conn.perform_request("GET", "/")
|
422 | 426 | assert str(e.value) == "Wasn't modified!"
|
423 | 427 |
|
| 428 | + @pytest.mark.parametrize("aiohttp_fixed_head_bug", [True, False]) |
| 429 | + async def test_head_workaround(self, aiohttp_fixed_head_bug, monkeypatch): |
| 430 | + monkeypatch.setattr( |
| 431 | + elasticsearch._async.http_aiohttp, |
| 432 | + "_AIOHTTP_FIXED_HEAD_BUG", |
| 433 | + aiohttp_fixed_head_bug, |
| 434 | + ) |
| 435 | + |
| 436 | + con = await self._get_mock_connection() |
| 437 | + await con.perform_request("HEAD", "/anything") |
| 438 | + |
| 439 | + method, url = con.session.request.call_args[0] |
| 440 | + assert method == "HEAD" if aiohttp_fixed_head_bug else "GET" |
| 441 | + assert url.human_repr() == "http://localhost:9200/anything" |
| 442 | + |
424 | 443 |
|
425 | 444 | class TestConnectionHttpbin:
|
426 | 445 | """Tests the HTTP connection implementations against a live server E2E"""
|
|
0 commit comments