Skip to content

Commit 8cce4d2

Browse files
hizixinCopilot
andcommitted
Clean up unit tests and bump spec pin
- Drop unit tests that only assert generated surface (inspect.signature checks, generated enum values, default api_version from generated _configuration.py, generated parent-model serialization). - Trim test_search_indexer_models.py to the two overload-contract tests that guard hand-written @overload signatures in indexes/models/_patch.py (SearchIndexerDataSourceConnection, SearchResourceEncryptionKey); add a module docstring explaining why. - Migrate async-test capability gates to aio.SearchClient.search.* and AsyncSearchItemPaged.get_debug_info so async tests gate the async public surface instead of the sync one. - Move SearchIndex.{cors_options, permission_filter_option, purview_enabled} gates onto test_list_indexes_with_select_forwards_ paging_kwargs (the test that actually exercises _convert_index_response). - Bump tsp-location.yaml from 4bb11e927c to merge commit 8be8c75d9b (squash-merge of the spec PR on main; tree-equivalent under specification/search/). 309 unit tests pass; mypy / pylint / black clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7835c90 commit 8cce4d2

8 files changed

Lines changed: 52 additions & 58 deletions

sdk/search/azure-search-documents/tests/_capabilities.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,27 @@ def _client_capabilities() -> Mapping[str, Mapping[str, Any]]:
353353
"SearchClient.search.query_source_authorization": _surface(
354354
"azure.search.documents.SearchClient.search", ("query_source_authorization",)
355355
),
356+
"aio.SearchClient.search.query_rewrites": _surface(
357+
"azure.search.documents.aio.SearchClient.search", ("query_rewrites",)
358+
),
359+
"aio.SearchClient.search.hybrid_search": _surface(
360+
"azure.search.documents.aio.SearchClient.search", ("hybrid_search",)
361+
),
362+
"aio.SearchClient.search.semantic_fields": _surface(
363+
"azure.search.documents.aio.SearchClient.search", ("semantic_fields",)
364+
),
365+
"aio.SearchClient.search.query_language": _surface(
366+
"azure.search.documents.aio.SearchClient.search", ("query_language",)
367+
),
368+
"aio.SearchClient.search.speller": _surface("azure.search.documents.aio.SearchClient.search", ("speller",)),
369+
"aio.SearchClient.search.enable_elevated_read": _surface(
370+
"azure.search.documents.aio.SearchClient.search", ("enable_elevated_read",)
371+
),
372+
"aio.SearchClient.search.query_source_authorization": _surface(
373+
"azure.search.documents.aio.SearchClient.search", ("query_source_authorization",)
374+
),
356375
"SearchItemPaged.get_debug_info": _surface("azure.search.documents.SearchItemPaged.get_debug_info"),
376+
"AsyncSearchItemPaged.get_debug_info": _surface("azure.search.documents.aio.AsyncSearchItemPaged.get_debug_info"),
357377
"KnowledgeBaseRetrievalClient": _surface("azure.search.documents.knowledgebases.KnowledgeBaseRetrievalClient"),
358378
"KnowledgeBaseRetrievalClient.aio": _surface(
359379
"azure.search.documents.knowledgebases.aio.KnowledgeBaseRetrievalClient"

sdk/search/azure-search-documents/tests/test_search_client.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,6 @@ def test_search_converts_atsearch_metadata_keys_on_each_result(self, mock_search
257257
assert document["@search.captions"][0].text == "summary"
258258
assert document["@search.document_debug_info"] is not None
259259

260-
@mock.patch("azure.search.documents._operations._operations._SearchClientOperationsMixin._search_post")
261-
def test_search_accepts_comma_delimited_select(self, mock_search_post):
262-
mock_search_post.return_value = create_search_documents_result()
263-
client = create_search_client()
264-
265-
result = client.search(search_text=SEARCH_TEXT, select="HotelId,HotelName")
266-
next(result)
267-
268-
assert get_search_request(mock_search_post).select == ["HotelId", "HotelName"]
269-
270260
@mock.patch("azure.search.documents._operations._operations._SearchClientOperationsMixin._search_post")
271261
def test_search_metadata_accessors_fetch_first_page_once_and_clear_continuation(self, mock_search_post):
272262
search_result = create_search_documents_result()

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ async def test_search_passes_query_language_speller_rewrites_semantic_fields_and
180180
self, mock_search_post
181181
):
182182
require_capability(
183-
"SearchClient.search.query_language",
184-
"SearchClient.search.speller",
185-
"SearchClient.search.query_rewrites",
186-
"SearchClient.search.semantic_fields",
187-
"SearchClient.search.hybrid_search",
183+
"aio.SearchClient.search.query_language",
184+
"aio.SearchClient.search.speller",
185+
"aio.SearchClient.search.query_rewrites",
186+
"aio.SearchClient.search.semantic_fields",
187+
"aio.SearchClient.search.hybrid_search",
188188
"azure.search.documents.models.HybridSearch",
189189
"azure.search.documents.models.HybridSearch.max_text_recall_size",
190190
"azure.search.documents.models.HybridSearch.count_and_facet_mode",
@@ -215,8 +215,8 @@ async def test_search_passes_query_language_speller_rewrites_semantic_fields_and
215215
@mock.patch("azure.search.documents.aio._operations._operations._SearchClientOperationsMixin._search_post")
216216
async def test_search_translates_legacy_x_ms_kwargs_to_generated_names(self, mock_search_post):
217217
require_capability(
218-
"SearchClient.search.enable_elevated_read",
219-
"SearchClient.search.query_source_authorization",
218+
"aio.SearchClient.search.enable_elevated_read",
219+
"aio.SearchClient.search.query_source_authorization",
220220
)
221221
mock_search_post.return_value = create_search_documents_result()
222222
async with create_search_client() as client:
@@ -260,16 +260,6 @@ async def test_search_converts_atsearch_metadata_keys_on_each_result(self, mock_
260260
assert document["@search.captions"][0].text == "summary"
261261
assert document["@search.document_debug_info"] is not None
262262

263-
@pytest.mark.asyncio
264-
@mock.patch("azure.search.documents.aio._operations._operations._SearchClientOperationsMixin._search_post")
265-
async def test_search_accepts_comma_delimited_select(self, mock_search_post):
266-
mock_search_post.return_value = create_search_documents_result()
267-
async with create_search_client() as client:
268-
result = await client.search(search_text=SEARCH_TEXT, select="HotelId,HotelName")
269-
await result.__anext__()
270-
271-
assert get_search_request(mock_search_post).select == ["HotelId", "HotelName"]
272-
273263
@pytest.mark.asyncio
274264
@mock.patch("azure.search.documents.aio._operations._operations._SearchClientOperationsMixin._search_post")
275265
async def test_search_metadata_accessors_fetch_first_page_once_and_clear_continuation(self, mock_search_post):
@@ -311,7 +301,7 @@ async def test_search_metadata_accessors_return_none_when_metadata_is_absent(sel
311301
async def test_get_debug_info_returns_response_debug_info(self, mock_search_post):
312302
require_capability(
313303
"azure.search.documents.models.DebugInfo",
314-
"SearchItemPaged.get_debug_info",
304+
"AsyncSearchItemPaged.get_debug_info",
315305
)
316306
from azure.search.documents.models import DebugInfo
317307

sdk/search/azure-search-documents/tests/test_search_field_helpers.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@
1717
SimpleField,
1818
)
1919

20-
CANONICAL_FIELD_TYPES = [
21-
("STRING", "Edm.String"),
22-
("INT32", "Edm.Int32"),
23-
("INT64", "Edm.Int64"),
24-
("SINGLE", "Edm.Single"),
25-
("DOUBLE", "Edm.Double"),
26-
("BOOLEAN", "Edm.Boolean"),
27-
("DATE_TIME_OFFSET", "Edm.DateTimeOffset"),
28-
("GEOGRAPHY_POINT", "Edm.GeographyPoint"),
29-
("COMPLEX", "Edm.ComplexType"),
30-
]
31-
3220

3321
def _assert_default_analyzer_settings(field):
3422
assert field.analyzer_name is None
@@ -38,10 +26,6 @@ def _assert_default_analyzer_settings(field):
3826

3927

4028
class TestSearchFieldDataType:
41-
@pytest.mark.parametrize(("name", "value"), CANONICAL_FIELD_TYPES)
42-
def test_canonical_members_keep_edm_values(self, name, value):
43-
assert getattr(SearchFieldDataType, name) == value
44-
4529
@pytest.mark.parametrize(
4630
("alias", "canonical"),
4731
[

sdk/search/azure-search-documents/tests/test_search_index_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def test_list_indexes_with_select_forwards_paging_kwargs(self, mock_list_select)
8686
"azure.search.documents.indexes.SearchIndexClient.list_indexes.top",
8787
"azure.search.documents.indexes.SearchIndexClient.list_indexes.skip",
8888
"azure.search.documents.indexes.SearchIndexClient.list_indexes.count",
89+
"azure.search.documents.indexes.models.SearchIndex.cors_options",
90+
"azure.search.documents.indexes.models.SearchIndex.permission_filter_option",
91+
"azure.search.documents.indexes.models.SearchIndex.purview_enabled",
8992
)
9093

9194
list(_client().list_indexes(select=["name"], top=3, skip=1, count=False))

sdk/search/azure-search-documents/tests/test_search_index_client_async.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ async def test_list_indexes_with_select_forwards_paging_kwargs(self):
8989
"azure.search.documents.indexes.aio.SearchIndexClient.list_indexes.top",
9090
"azure.search.documents.indexes.aio.SearchIndexClient.list_indexes.skip",
9191
"azure.search.documents.indexes.aio.SearchIndexClient.list_indexes.count",
92+
"azure.search.documents.indexes.models.SearchIndex.cors_options",
93+
"azure.search.documents.indexes.models.SearchIndex.permission_filter_option",
94+
"azure.search.documents.indexes.models.SearchIndex.purview_enabled",
9295
)
9396

9497
with mock.patch(

sdk/search/azure-search-documents/tests/test_search_indexer_models.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@
33
# Copyright (c) Microsoft Corporation.
44
# Licensed under the MIT License.
55
# ------------------------------------
6-
"""Unit tests for search indexer model helper serialization."""
6+
"""Unit tests for hand-written overload contracts on indexer models.
7+
8+
These tests verify the public API promises declared by `@overload`
9+
signatures in `azure.search.documents.indexes.models._patch`:
10+
11+
* `SearchIndexerDataSourceConnection(connection_string=...)` is a
12+
hand-written alternative to passing `credentials=DataSourceCredentials(...)`.
13+
* `SearchResourceEncryptionKey()` accepts a no-arg construction and
14+
exposes `is_service_level_key` as an optional preview-only field.
15+
16+
If a future regeneration changes the generated parent so these
17+
constructions fail or serialize differently, these tests catch the
18+
silent regression before it reaches customers.
19+
"""
720

821
from __future__ import annotations
922

@@ -16,13 +29,13 @@
1629

1730
from _capabilities import require_capability
1831

32+
1933
DATA_SOURCE_NAME = "hotel-data-source"
2034
CONNECTION_STRING = (
2135
"ResourceId=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/search/"
2236
"providers/Microsoft.Storage/storageAccounts/hotels"
2337
)
2438
CONTAINER_NAME = "hotel-documents"
25-
REPLACEMENT_CONNECTION_STRING = "<unchanged>"
2639

2740

2841
def create_data_source(connection_string=CONNECTION_STRING):
@@ -34,7 +47,7 @@ def create_data_source(connection_string=CONNECTION_STRING):
3447
)
3548

3649

37-
class TestSearchIndexerDataSourceConnectionSerialization:
50+
class TestSearchIndexerDataSourceConnectionOverloads:
3851
def test_connection_string_overload_serializes_as_nested_credentials(self):
3952
data_source = create_data_source()
4053

@@ -47,17 +60,8 @@ def test_connection_string_overload_serializes_as_nested_credentials(self):
4760
"container": {"name": CONTAINER_NAME},
4861
}
4962

50-
def test_connection_string_property_round_trips_through_credentials(self):
51-
data_source = create_data_source()
52-
53-
data_source.connection_string = REPLACEMENT_CONNECTION_STRING
54-
55-
assert data_source.connection_string == REPLACEMENT_CONNECTION_STRING
56-
assert data_source.credentials.connection_string == REPLACEMENT_CONNECTION_STRING
57-
assert data_source.as_dict()["credentials"] == {"connectionString": REPLACEMENT_CONNECTION_STRING}
58-
5963

60-
class TestSearchResourceEncryptionKey:
64+
class TestSearchResourceEncryptionKeyOverloads:
6165
def test_search_resource_encryption_key_allows_service_level_key_without_vault_details(self):
6266
require_capability("azure.search.documents.indexes.models.SearchResourceEncryptionKey.is_service_level_key")
6367

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
directory: specification/search/data-plane/Search
2-
commit: 4bb11e927c04ffcc6cb762e4f3374ffd6571590a
2+
commit: 8be8c75d9bb11ea95d8a7e251db74aa78b5cd76c
33
repo: Azure/azure-rest-api-specs
44

0 commit comments

Comments
 (0)