forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reset continuation token (Azure#18772)
* reset continuation token * add tests * update
- Loading branch information
1 parent
ef56f99
commit 20a3129
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
sdk/search/azure-search-documents/tests/async_tests/test_search_client_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
try: | ||
from unittest import mock | ||
except ImportError: | ||
import mock | ||
from azure.core.credentials import AzureKeyCredential | ||
from azure.search.documents._generated.models import SearchDocumentsResult, SearchResult | ||
from azure.search.documents.aio import SearchClient | ||
from azure.search.documents.aio._search_client_async import AsyncSearchPageIterator | ||
|
||
CREDENTIAL = AzureKeyCredential(key="test_api_key") | ||
|
||
class TestSearchClientAsync(object): | ||
@mock.patch( | ||
"azure.search.documents._generated.aio.operations._documents_operations.DocumentsOperations.search_post" | ||
) | ||
async def test_get_count_reset_continuation_token(self, mock_search_post): | ||
client = SearchClient("endpoint", "index name", CREDENTIAL) | ||
result = await client.search(search_text="search text") | ||
assert result._page_iterator_class is AsyncSearchPageIterator | ||
search_result = SearchDocumentsResult() | ||
search_result.results = [SearchResult(additional_properties={"key": "val"})] | ||
mock_search_post.return_value = search_result | ||
await result.__anext__() | ||
result._first_page_iterator_instance.continuation_token = "fake token" | ||
await result.get_count() | ||
assert not result._first_page_iterator_instance.continuation_token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters