Skip to content

Commit cc55688

Browse files
authored
add missing async decorator (#35188)
1 parent 9181673 commit cc55688

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

sdk/search/azure-search-documents/tests/async_tests/test_buffered_sender_async.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
from azure.core.credentials import AzureKeyCredential
1111
from azure.core.exceptions import HttpResponseError, ServiceResponseTimeoutError
1212
from azure.search.documents.models import IndexingResult
13+
from test_search_index_client_async import await_prepared_test
1314

1415
CREDENTIAL = AzureKeyCredential(key="test_api_key")
1516

1617

1718
class 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:

sdk/search/azure-search-documents/tests/async_tests/test_search_client_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
from azure.search.documents._generated.models import SearchDocumentsResult, SearchResult
88
from azure.search.documents.aio import SearchClient
99
from azure.search.documents.aio._search_client_async import AsyncSearchPageIterator
10+
from test_search_index_client_async import await_prepared_test
1011

1112
CREDENTIAL = AzureKeyCredential(key="test_api_key")
1213

1314

1415
class TestSearchClientAsync:
16+
@await_prepared_test
1517
@mock.patch(
1618
"azure.search.documents._generated.aio.operations._documents_operations.DocumentsOperations.search_post"
1719
)

0 commit comments

Comments
 (0)