Skip to content

Commit f5b517a

Browse files
committed
Fix lint
1 parent 845c3bd commit f5b517a

File tree

2 files changed

+220
-184
lines changed

2 files changed

+220
-184
lines changed

test_elasticsearch_serverless/test_async/test_server/test_helpers.py

Lines changed: 83 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
498498
bulk.append({"value": x})
499499
await async_client.bulk(operations=bulk, refresh=True)
500500

501-
with patch.object(
502-
async_client, "options", return_value=async_client
503-
), patch.object(async_client, "scroll", MockScroll()):
501+
with (
502+
patch.object(async_client, "options", return_value=async_client),
503+
patch.object(async_client, "scroll", MockScroll()),
504+
):
504505
data = [
505506
x
506507
async for x in helpers.async_scan(
@@ -514,9 +515,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
514515
assert len(data) == 3
515516
assert data[-1] == {"scroll_data": 42}
516517

517-
with patch.object(
518-
async_client, "options", return_value=async_client
519-
), patch.object(async_client, "scroll", MockScroll()):
518+
with (
519+
patch.object(async_client, "options", return_value=async_client),
520+
patch.object(async_client, "scroll", MockScroll()),
521+
):
520522
with pytest.raises(ScanError):
521523
data = [
522524
x
@@ -532,9 +534,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
532534
assert data[-1] == {"scroll_data": 42}
533535

534536
async def test_initial_search_error(self, async_client, scan_teardown):
535-
with patch.object(
536-
async_client, "options", return_value=async_client
537-
), patch.object(async_client, "clear_scroll", new_callable=AsyncMock):
537+
with (
538+
patch.object(async_client, "options", return_value=async_client),
539+
patch.object(async_client, "clear_scroll", new_callable=AsyncMock),
540+
):
538541
with patch.object(
539542
async_client,
540543
"search",
@@ -590,15 +593,16 @@ async def test_initial_search_error(self, async_client, scan_teardown):
590593
assert mock_scroll.calls == []
591594

592595
async def test_no_scroll_id_fast_route(self, async_client, scan_teardown):
593-
with patch.object(
594-
async_client, "options", return_value=async_client
595-
), patch.object(async_client, "scroll") as scroll_mock, patch.object(
596-
async_client,
597-
"search",
598-
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
599-
), patch.object(
600-
async_client, "clear_scroll"
601-
) as clear_mock:
596+
with (
597+
patch.object(async_client, "options", return_value=async_client),
598+
patch.object(async_client, "scroll") as scroll_mock,
599+
patch.object(
600+
async_client,
601+
"search",
602+
MockResponse(ObjectApiResponse(body={"no": "_scroll_id"}, meta=None)),
603+
),
604+
patch.object(async_client, "clear_scroll") as clear_mock,
605+
):
602606
data = [
603607
x async for x in helpers.async_scan(async_client, index="test_index")
604608
]
@@ -615,9 +619,10 @@ async def test_logger(self, logger_mock, async_client, scan_teardown):
615619
bulk.append({"value": x})
616620
await async_client.bulk(operations=bulk, refresh=True)
617621

618-
with patch.object(
619-
async_client, "options", return_value=async_client
620-
), patch.object(async_client, "scroll", MockScroll()):
622+
with (
623+
patch.object(async_client, "options", return_value=async_client),
624+
patch.object(async_client, "scroll", MockScroll()),
625+
):
621626
_ = [
622627
x
623628
async for x in helpers.async_scan(
@@ -630,9 +635,10 @@ async def test_logger(self, logger_mock, async_client, scan_teardown):
630635
]
631636
logger_mock.warning.assert_called()
632637

633-
with patch.object(
634-
async_client, "options", return_value=async_client
635-
), patch.object(async_client, "scroll", MockScroll()):
638+
with (
639+
patch.object(async_client, "options", return_value=async_client),
640+
patch.object(async_client, "scroll", MockScroll()),
641+
):
636642
try:
637643
_ = [
638644
x
@@ -660,11 +666,12 @@ async def test_clear_scroll(self, async_client, scan_teardown):
660666
bulk.append({"value": x})
661667
await async_client.bulk(operations=bulk, refresh=True)
662668

663-
with patch.object(
664-
async_client, "options", return_value=async_client
665-
), patch.object(
666-
async_client, "clear_scroll", wraps=async_client.clear_scroll
667-
) as spy:
669+
with (
670+
patch.object(async_client, "options", return_value=async_client),
671+
patch.object(
672+
async_client, "clear_scroll", wraps=async_client.clear_scroll
673+
) as spy,
674+
):
668675
_ = [
669676
x
670677
async for x in helpers.async_scan(
@@ -702,20 +709,21 @@ async def test_clear_scroll(self, async_client, scan_teardown):
702709
async def test_scan_auth_kwargs_forwarded(
703710
self, async_client, scan_teardown, kwargs
704711
):
705-
with patch.object(
706-
async_client, "options", return_value=async_client
707-
) as options, patch.object(
708-
async_client,
709-
"search",
710-
return_value=MockResponse(
711-
ObjectApiResponse(
712-
body={
713-
"_scroll_id": "scroll_id",
714-
"_shards": {"successful": 5, "total": 5, "skipped": 0},
715-
"hits": {"hits": [{"search_data": 1}]},
716-
},
717-
meta=None,
718-
)
712+
with (
713+
patch.object(async_client, "options", return_value=async_client) as options,
714+
patch.object(
715+
async_client,
716+
"search",
717+
return_value=MockResponse(
718+
ObjectApiResponse(
719+
body={
720+
"_scroll_id": "scroll_id",
721+
"_shards": {"successful": 5, "total": 5, "skipped": 0},
722+
"hits": {"hits": [{"search_data": 1}]},
723+
},
724+
meta=None,
725+
)
726+
),
719727
),
720728
):
721729
with patch.object(
@@ -755,20 +763,21 @@ async def test_scan_auth_kwargs_forwarded(
755763
async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
756764
self, async_client, scan_teardown
757765
):
758-
with patch.object(
759-
async_client, "options", return_value=async_client
760-
) as options, patch.object(
761-
async_client,
762-
"search",
763-
return_value=MockResponse(
764-
ObjectApiResponse(
765-
body={
766-
"_scroll_id": "scroll_id",
767-
"_shards": {"successful": 5, "total": 5, "skipped": 0},
768-
"hits": {"hits": [{"search_data": 1}]},
769-
},
770-
meta=None,
771-
)
766+
with (
767+
patch.object(async_client, "options", return_value=async_client) as options,
768+
patch.object(
769+
async_client,
770+
"search",
771+
return_value=MockResponse(
772+
ObjectApiResponse(
773+
body={
774+
"_scroll_id": "scroll_id",
775+
"_shards": {"successful": 5, "total": 5, "skipped": 0},
776+
"hits": {"hits": [{"search_data": 1}]},
777+
},
778+
meta=None,
779+
)
780+
),
772781
),
773782
):
774783
with patch.object(
@@ -832,21 +841,23 @@ async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
832841
],
833842
)
834843
async def test_scan_from_keyword_is_aliased(async_client, scan_kwargs):
835-
with patch.object(async_client, "options", return_value=async_client), patch.object(
836-
async_client,
837-
"search",
838-
return_value=MockResponse(
839-
ObjectApiResponse(
840-
body={
841-
"_scroll_id": "dummy_id",
842-
"_shards": {"successful": 5, "total": 5},
843-
"hits": {"hits": []},
844-
},
845-
meta=None,
846-
)
847-
),
848-
) as search_mock, patch.object(
849-
async_client, "clear_scroll", return_value=MockResponse(None)
844+
with (
845+
patch.object(async_client, "options", return_value=async_client),
846+
patch.object(
847+
async_client,
848+
"search",
849+
return_value=MockResponse(
850+
ObjectApiResponse(
851+
body={
852+
"_scroll_id": "dummy_id",
853+
"_shards": {"successful": 5, "total": 5},
854+
"hits": {"hits": []},
855+
},
856+
meta=None,
857+
)
858+
),
859+
) as search_mock,
860+
patch.object(async_client, "clear_scroll", return_value=MockResponse(None)),
850861
):
851862
[
852863
x

0 commit comments

Comments
 (0)