1010from azure .core .credentials import AzureKeyCredential
1111from azure .core .exceptions import HttpResponseError , ServiceResponseTimeoutError
1212from azure .search .documents .models import IndexingResult
13+ from test_search_index_client_async import await_prepared_test
1314
1415CREDENTIAL = AzureKeyCredential (key = "test_api_key" )
1516
1617
1718class TestSearchBatchingClientAsync :
19+ @await_prepared_test
1820 async def test_search_indexing_buffered_sender_kwargs (self ):
1921 async with SearchIndexingBufferedSender ("endpoint" , "index name" , CREDENTIAL , window = 100 ) as client :
2022 assert client ._batch_action_count == 512
2123 assert client ._max_retries_per_action == 3
2224 assert client ._auto_flush_interval == 60
2325 assert client ._auto_flush
2426
27+ @await_prepared_test
2528 async def test_batch_queue (self ):
2629 async with SearchIndexingBufferedSender ("endpoint" , "index name" , CREDENTIAL , auto_flush = False ) as client :
2730 assert client ._index_documents_batch
@@ -35,6 +38,7 @@ async def test_batch_queue(self):
3538 await client ._index_documents_batch .enqueue_actions (actions )
3639 assert len (client .actions ) == 7
3740
41+ @await_prepared_test
3842 @mock .patch (
3943 "azure.search.documents.aio._search_indexing_buffered_sender_async.SearchIndexingBufferedSender._process_if_needed"
4044 )
@@ -44,6 +48,7 @@ async def test_process_if_needed(self, mock_process_if_needed):
4448 await client .delete_documents (["delete1" , "delete2" ])
4549 assert mock_process_if_needed .called
4650
51+ @await_prepared_test
4752 @mock .patch (
4853 "azure.search.documents.aio._search_indexing_buffered_sender_async.SearchIndexingBufferedSender._cleanup"
4954 )
@@ -53,6 +58,7 @@ async def test_context_manager(self, mock_cleanup):
5358 await client .delete_documents (["delete1" , "delete2" ])
5459 assert mock_cleanup .called
5560
61+ @await_prepared_test
5662 async def test_flush (self ):
5763 DOCUMENT = {
5864 "category" : "Hotel" ,
@@ -72,6 +78,7 @@ async def test_flush(self):
7278 await client .flush ()
7379 assert len (client .actions ) == 0
7480
81+ @await_prepared_test
7582 async def test_callback_new (self ):
7683 on_new = mock .AsyncMock ()
7784 async with SearchIndexingBufferedSender (
@@ -80,6 +87,7 @@ async def test_callback_new(self):
8087 await client .upload_documents (["upload1" ])
8188 assert on_new .called
8289
90+ @await_prepared_test
8391 async def test_callback_error (self ):
8492 async def mock_fail_index_documents (actions , timeout = 86400 ):
8593 if len (actions ) > 0 :
@@ -100,6 +108,7 @@ async def mock_fail_index_documents(actions, timeout=86400):
100108 await client .flush ()
101109 assert on_error .called
102110
111+ @await_prepared_test
103112 async def test_callback_error_on_timeout (self ):
104113 async def mock_fail_index_documents (actions , timeout = 86400 ):
105114 if len (actions ) > 0 :
@@ -122,6 +131,7 @@ async def mock_fail_index_documents(actions, timeout=86400):
122131 await client .flush (timeout = - 1 )
123132 assert on_error .call_count == 2
124133
134+ @await_prepared_test
125135 async def test_callback_progress (self ):
126136 async def mock_successful_index_documents (actions , timeout = 86400 ):
127137 if len (actions ) > 0 :
0 commit comments