@@ -542,9 +542,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
542
542
bulk .append ({"value" : x })
543
543
await async_client .bulk (operations = bulk , refresh = True )
544
544
545
- with patch .object (
546
- async_client , "options" , return_value = async_client
547
- ), patch .object (async_client , "scroll" , MockScroll ()):
545
+ with (
546
+ patch .object (async_client , "options" , return_value = async_client ),
547
+ patch .object (async_client , "scroll" , MockScroll ()),
548
+ ):
548
549
data = [
549
550
x
550
551
async for x in helpers .async_scan (
@@ -558,9 +559,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
558
559
assert len (data ) == 3
559
560
assert data [- 1 ] == {"scroll_data" : 42 }
560
561
561
- with patch .object (
562
- async_client , "options" , return_value = async_client
563
- ), patch .object (async_client , "scroll" , MockScroll ()):
562
+ with (
563
+ patch .object (async_client , "options" , return_value = async_client ),
564
+ patch .object (async_client , "scroll" , MockScroll ()),
565
+ ):
564
566
with pytest .raises (ScanError ):
565
567
data = [
566
568
x
@@ -576,9 +578,10 @@ async def test_scroll_error(self, async_client, scan_teardown):
576
578
assert data [- 1 ] == {"scroll_data" : 42 }
577
579
578
580
async def test_initial_search_error (self , async_client , scan_teardown ):
579
- with patch .object (
580
- async_client , "options" , return_value = async_client
581
- ), patch .object (async_client , "clear_scroll" , new_callable = AsyncMock ):
581
+ with (
582
+ patch .object (async_client , "options" , return_value = async_client ),
583
+ patch .object (async_client , "clear_scroll" , new_callable = AsyncMock ),
584
+ ):
582
585
with patch .object (
583
586
async_client ,
584
587
"search" ,
@@ -634,15 +637,16 @@ async def test_initial_search_error(self, async_client, scan_teardown):
634
637
assert mock_scroll .calls == []
635
638
636
639
async def test_no_scroll_id_fast_route (self , async_client , scan_teardown ):
637
- with patch .object (
638
- async_client , "options" , return_value = async_client
639
- ), patch .object (async_client , "scroll" ) as scroll_mock , patch .object (
640
- async_client ,
641
- "search" ,
642
- MockResponse (ObjectApiResponse (body = {"no" : "_scroll_id" }, meta = None )),
643
- ), patch .object (
644
- async_client , "clear_scroll"
645
- ) as clear_mock :
640
+ with (
641
+ patch .object (async_client , "options" , return_value = async_client ),
642
+ patch .object (async_client , "scroll" ) as scroll_mock ,
643
+ patch .object (
644
+ async_client ,
645
+ "search" ,
646
+ MockResponse (ObjectApiResponse (body = {"no" : "_scroll_id" }, meta = None )),
647
+ ),
648
+ patch .object (async_client , "clear_scroll" ) as clear_mock ,
649
+ ):
646
650
data = [
647
651
x async for x in helpers .async_scan (async_client , index = "test_index" )
648
652
]
@@ -661,9 +665,10 @@ async def test_logger(
661
665
bulk .append ({"value" : x })
662
666
await async_client .bulk (operations = bulk , refresh = True )
663
667
664
- with patch .object (
665
- async_client , "options" , return_value = async_client
666
- ), patch .object (async_client , "scroll" , MockScroll ()):
668
+ with (
669
+ patch .object (async_client , "options" , return_value = async_client ),
670
+ patch .object (async_client , "scroll" , MockScroll ()),
671
+ ):
667
672
_ = [
668
673
x
669
674
async for x in helpers .async_scan (
@@ -680,9 +685,10 @@ async def test_logger(
680
685
]
681
686
682
687
caplog .clear ()
683
- with patch .object (
684
- async_client , "options" , return_value = async_client
685
- ), patch .object (async_client , "scroll" , MockScroll ()):
688
+ with (
689
+ patch .object (async_client , "options" , return_value = async_client ),
690
+ patch .object (async_client , "scroll" , MockScroll ()),
691
+ ):
686
692
with pytest .raises (ScanError ):
687
693
_ = [
688
694
x
@@ -706,11 +712,12 @@ async def test_clear_scroll(self, async_client, scan_teardown):
706
712
bulk .append ({"value" : x })
707
713
await async_client .bulk (operations = bulk , refresh = True )
708
714
709
- with patch .object (
710
- async_client , "options" , return_value = async_client
711
- ), patch .object (
712
- async_client , "clear_scroll" , wraps = async_client .clear_scroll
713
- ) as spy :
715
+ with (
716
+ patch .object (async_client , "options" , return_value = async_client ),
717
+ patch .object (
718
+ async_client , "clear_scroll" , wraps = async_client .clear_scroll
719
+ ) as spy ,
720
+ ):
714
721
_ = [
715
722
x
716
723
async for x in helpers .async_scan (
@@ -748,20 +755,21 @@ async def test_clear_scroll(self, async_client, scan_teardown):
748
755
async def test_scan_auth_kwargs_forwarded (
749
756
self , async_client , scan_teardown , kwargs
750
757
):
751
- with patch .object (
752
- async_client , "options" , return_value = async_client
753
- ) as options , patch .object (
754
- async_client ,
755
- "search" ,
756
- return_value = MockResponse (
757
- ObjectApiResponse (
758
- body = {
759
- "_scroll_id" : "scroll_id" ,
760
- "_shards" : {"successful" : 5 , "total" : 5 , "skipped" : 0 },
761
- "hits" : {"hits" : [{"search_data" : 1 }]},
762
- },
763
- meta = None ,
764
- )
758
+ with (
759
+ patch .object (async_client , "options" , return_value = async_client ) as options ,
760
+ 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
+ )
772
+ ),
765
773
),
766
774
):
767
775
with patch .object (
@@ -801,20 +809,21 @@ async def test_scan_auth_kwargs_forwarded(
801
809
async def test_scan_auth_kwargs_favor_scroll_kwargs_option (
802
810
self , async_client , scan_teardown
803
811
):
804
- with patch .object (
805
- async_client , "options" , return_value = async_client
806
- ) as options , patch .object (
807
- async_client ,
808
- "search" ,
809
- return_value = MockResponse (
810
- ObjectApiResponse (
811
- body = {
812
- "_scroll_id" : "scroll_id" ,
813
- "_shards" : {"successful" : 5 , "total" : 5 , "skipped" : 0 },
814
- "hits" : {"hits" : [{"search_data" : 1 }]},
815
- },
816
- meta = None ,
817
- )
812
+ with (
813
+ patch .object (async_client , "options" , return_value = async_client ) as options ,
814
+ patch .object (
815
+ async_client ,
816
+ "search" ,
817
+ return_value = MockResponse (
818
+ ObjectApiResponse (
819
+ body = {
820
+ "_scroll_id" : "scroll_id" ,
821
+ "_shards" : {"successful" : 5 , "total" : 5 , "skipped" : 0 },
822
+ "hits" : {"hits" : [{"search_data" : 1 }]},
823
+ },
824
+ meta = None ,
825
+ )
826
+ ),
818
827
),
819
828
):
820
829
with patch .object (
@@ -878,21 +887,23 @@ async def test_scan_auth_kwargs_favor_scroll_kwargs_option(
878
887
],
879
888
)
880
889
async def test_scan_from_keyword_is_aliased (async_client , scan_kwargs ):
881
- with patch .object (async_client , "options" , return_value = async_client ), patch .object (
882
- async_client ,
883
- "search" ,
884
- return_value = MockResponse (
885
- ObjectApiResponse (
886
- body = {
887
- "_scroll_id" : "dummy_id" ,
888
- "_shards" : {"successful" : 5 , "total" : 5 },
889
- "hits" : {"hits" : []},
890
- },
891
- meta = None ,
892
- )
893
- ),
894
- ) as search_mock , patch .object (
895
- async_client , "clear_scroll" , return_value = MockResponse (None )
890
+ with (
891
+ patch .object (async_client , "options" , return_value = async_client ),
892
+ patch .object (
893
+ async_client ,
894
+ "search" ,
895
+ return_value = MockResponse (
896
+ ObjectApiResponse (
897
+ body = {
898
+ "_scroll_id" : "dummy_id" ,
899
+ "_shards" : {"successful" : 5 , "total" : 5 },
900
+ "hits" : {"hits" : []},
901
+ },
902
+ meta = None ,
903
+ )
904
+ ),
905
+ ) as search_mock ,
906
+ patch .object (async_client , "clear_scroll" , return_value = MockResponse (None )),
896
907
):
897
908
[
898
909
x
0 commit comments