From f603b3deafc97db9715f185388f82a3b8a364746 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:49:54 +0000 Subject: [PATCH 01/21] Initial plan From ee65d6b7d3467b5833e2d21da43440b1fe0d7e1c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:56:09 +0000 Subject: [PATCH 02/21] feat(http-client-python): add mock API test for payload/head scenario Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/6b24cfbf-9b6f-4272-afae-99bea1b0548c Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...oad-head-python-test-2026-4-17-22-55-53.md | 7 ++++++ .../eng/scripts/ci/regenerate-common.ts | 3 +++ packages/http-client-python/package-lock.json | 25 +++++++++---------- packages/http-client-python/package.json | 2 +- .../asynctests/test_payload_head_async.py | 19 ++++++++++++++ .../mock_api/shared/test_payload_head.py | 17 +++++++++++++ 6 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 .chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md create mode 100644 packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py create mode 100644 packages/http-client-python/tests/mock_api/shared/test_payload_head.py diff --git a/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md b/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md new file mode 100644 index 00000000000..ee198e709bd --- /dev/null +++ b/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test for `payload/head` scenario with `Content-Type` and `x-ms-meta` response headers. diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index f54fe034663..1660e263a14 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -123,6 +123,9 @@ export const BASE_AZURE_EMITTER_OPTIONS: Record< "payload/content-negotiation": { namespace: "payload.contentnegotiation", }, + "payload/head": { + namespace: "payload.head", + }, "payload/multipart": { namespace: "payload.multipart", }, diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index a6129262122..0f1ae596b23 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.11.0", "@typespec/events": "~0.81.0", "@typespec/http": "^1.11.0", - "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/http-specs": "0.1.0-alpha.37-dev.3", "@typespec/openapi": "^1.11.0", "@typespec/rest": "~0.81.0", "@typespec/spec-api": "0.1.0-alpha.14", @@ -2520,25 +2520,24 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.36", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.36.tgz", - "integrity": "sha512-2nwh4YIx7MIwkVV8pZWUgp9dgR9U937MANtJvVILcWLLaBTVfLPXNQZjzDccFozzk8QxL7dBWA/gm7i6lsHZcA==", + "version": "0.1.0-alpha.37-dev.3", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.37-dev.3.tgz", + "integrity": "sha512-CJdJKxFd4XI77kmCRBGMuhIcq8M5CvduyFFixA51FTzVcHrM1RXe9L6CUSNDc/JJe/3TLeSEbntrAOqWOxVyDA==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14", - "@typespec/spector": "^0.1.0-alpha.25", - "deep-equal": "^2.2.3" + "@typespec/spec-api": "^0.1.0-alpha.14 || >= 0.1.0-dev.3", + "@typespec/spector": "^0.1.0-alpha.25 || >= 0.1.0-dev.4" }, "engines": { - "node": ">=16.0.0" + "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.11.0", - "@typespec/http": "^1.11.0", - "@typespec/rest": "^0.81.0", - "@typespec/versioning": "^0.81.0", - "@typespec/xml": "^0.81.0" + "@typespec/compiler": "^1.11.0 || >= 1.12.0-dev.4", + "@typespec/http": "^1.11.0 || >= 1.12.0-dev.2", + "@typespec/rest": "^0.81.0 || >= 0.82.0-dev.2", + "@typespec/versioning": "^0.81.0 || >= 0.82.0-dev.2", + "@typespec/xml": "^0.81.0 || >= 0.82.0-dev.2" } }, "node_modules/@typespec/openapi": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 1b911555093..750d898e322 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -115,7 +115,7 @@ "@typespec/sse": "~0.81.0", "@typespec/streams": "~0.81.0", "@typespec/xml": "~0.81.0", - "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/http-specs": "0.1.0-alpha.37-dev.3", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py new file mode 100644 index 00000000000..41a421c8fd7 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py @@ -0,0 +1,19 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from payload.head.aio import HeadClient + + +@pytest_asyncio.fixture +async def client(): + async with HeadClient(endpoint="http://localhost:3000") as client: + yield client + + +@pytest.mark.asyncio +async def test_content_type_header_in_response(client: HeadClient): + assert await client.content_type_header_in_response() is True diff --git a/packages/http-client-python/tests/mock_api/shared/test_payload_head.py b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py new file mode 100644 index 00000000000..e179d8d2c89 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from payload.head import HeadClient + + +@pytest.fixture +def client(): + with HeadClient(endpoint="http://localhost:3000") as client: + yield client + + +def test_content_type_header_in_response(client: HeadClient): + assert client.content_type_header_in_response() is True From 6ace06667c46bb634505da2532f8bda468c239bd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Apr 2026 23:00:52 +0000 Subject: [PATCH 03/21] Initial plan From 789742f4373217511c72194cd4dcaf45e4cd1087 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Apr 2026 23:09:48 +0000 Subject: [PATCH 04/21] feat(http-client-python): add test cases for reserved operation body params (PR #10529) Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/3646352b-123b-42b2-93f9-d2824237c1a4 Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...tion-body-params-test-2026-4-28-23-10-0.md | 7 ++++++ packages/http-client-python/package-lock.json | 25 +++++++++---------- packages/http-client-python/package.json | 2 +- .../asynctests/test_special_words_async.py | 5 ++++ .../mock_api/azure/test_special_words.py | 4 +++ .../asynctests/test_special_words_async.py | 5 ++++ .../mock_api/unbranded/test_special_words.py | 4 +++ 7 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 .chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md diff --git a/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md b/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md new file mode 100644 index 00000000000..ad10ee1042b --- /dev/null +++ b/.chronus/changes/python-reserved-operation-body-params-test-2026-4-28-23-10-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test cases for operation body parameters with reserved names (e.g., `items`) to verify the wire name is not mangled. diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index a6129262122..7b839485b69 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.11.0", "@typespec/events": "~0.81.0", "@typespec/http": "^1.11.0", - "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/http-specs": "0.1.0-alpha.37-dev.4", "@typespec/openapi": "^1.11.0", "@typespec/rest": "~0.81.0", "@typespec/spec-api": "0.1.0-alpha.14", @@ -2520,25 +2520,24 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.36", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.36.tgz", - "integrity": "sha512-2nwh4YIx7MIwkVV8pZWUgp9dgR9U937MANtJvVILcWLLaBTVfLPXNQZjzDccFozzk8QxL7dBWA/gm7i6lsHZcA==", + "version": "0.1.0-alpha.37-dev.4", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.37-dev.4.tgz", + "integrity": "sha512-VgOSPLcfXtEZGR4E1o17AWMKvnxRXDZCd95dU/cPpT0EdeHS22aRsksQrXoP8oUbW8jV3BF4ZiEvtUrdKJ88qg==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14", - "@typespec/spector": "^0.1.0-alpha.25", - "deep-equal": "^2.2.3" + "@typespec/spec-api": "^0.1.0-alpha.14 || >= 0.1.0-dev.3", + "@typespec/spector": "^0.1.0-alpha.25 || >= 0.1.0-dev.4" }, "engines": { - "node": ">=16.0.0" + "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.11.0", - "@typespec/http": "^1.11.0", - "@typespec/rest": "^0.81.0", - "@typespec/versioning": "^0.81.0", - "@typespec/xml": "^0.81.0" + "@typespec/compiler": "^1.11.0 || >= 1.12.0-dev.4", + "@typespec/http": "^1.11.0 || >= 1.12.0-dev.2", + "@typespec/rest": "^0.81.0 || >= 0.82.0-dev.2", + "@typespec/versioning": "^0.81.0 || >= 0.82.0-dev.2", + "@typespec/xml": "^0.81.0 || >= 0.82.0-dev.2" } }, "node_modules/@typespec/openapi": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 644950c2daf..c94d17d97d0 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -115,7 +115,7 @@ "@typespec/sse": "~0.81.0", "@typespec/streams": "~0.81.0", "@typespec/xml": "~0.81.0", - "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/http-specs": "0.1.0-alpha.37-dev.4", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py index 8c59ea05070..78650db138d 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_special_words_async.py @@ -70,3 +70,8 @@ async def test_model_properties_with_list(client: SpecialWordsClient): async def test_extensible_strings(client: SpecialWordsClient): for enum_value in models.ExtensibleString: assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value) + + +@pytest.mark.asyncio +async def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + await client.reserved_operation_body_params.with_items(items=["item"]) diff --git a/packages/http-client-python/tests/mock_api/azure/test_special_words.py b/packages/http-client-python/tests/mock_api/azure/test_special_words.py index ab23b59409f..234301dede1 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_special_words.py +++ b/packages/http-client-python/tests/mock_api/azure/test_special_words.py @@ -61,3 +61,7 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): for enum_value in models.ExtensibleString: assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value) + + +def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + client.reserved_operation_body_params.with_items(items=["item"]) diff --git a/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py b/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py index c1e3bc0a8f2..5b8dcebaf1f 100644 --- a/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py +++ b/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_special_words_async.py @@ -72,3 +72,8 @@ async def test_model_properties_with_list(client: SpecialWordsClient): async def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value) + + +@pytest.mark.asyncio +async def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + await client.reserved_operation_body_params.with_items(items=["item"]) diff --git a/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py b/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py index 83269cc1e47..9da0330a805 100644 --- a/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py +++ b/packages/http-client-python/tests/mock_api/unbranded/test_special_words.py @@ -64,3 +64,7 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value) + + +def test_reserved_operation_body_params_with_items(client: SpecialWordsClient): + client.reserved_operation_body_params.with_items(items=["item"]) From 7acec0ca3f23ccbb6a6c0d61e6b8994e196199f5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 23:00:36 +0000 Subject: [PATCH 05/21] Initial plan From 0bb8ead57adb02569849fa9b10b019a7171a4fd5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 23:09:45 +0000 Subject: [PATCH 06/21] test(python): add test_head_model for type/model/visibility spec Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/8f8d4b76-f966-467e-a36d-35eab81c39e3 Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../add-visibility-head-model-test-2026-5-4-23-8-9.md | 7 +++++++ .../asynctests/test_typetest_model_visibility_async.py | 5 +++++ .../mock_api/shared/test_typetest_model_visibility.py | 4 ++++ 3 files changed, 16 insertions(+) create mode 100644 .chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md diff --git a/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md b/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md new file mode 100644 index 00000000000..26893a4c4dc --- /dev/null +++ b/.chronus/changes/add-visibility-head-model-test-2026-5-4-23-8-9.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add test coverage for `headModel` scenario in `type/model/visibility` spec. diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py index 62827695819..d5038fcd7de 100644 --- a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_visibility_async.py @@ -21,6 +21,11 @@ async def test_get_model(client): assert result == models.VisibilityModel(read_prop="abc") +@pytest.mark.asyncio +async def test_head_model(client): + assert await client.head_model(models.VisibilityModel(), query_prop=123) + + @pytest.mark.asyncio async def test_put_model(client): await client.put_model(models.VisibilityModel(create_prop=["foo", "bar"], update_prop=[1, 2])) diff --git a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py index c6f4695f2fa..ddbe78d2e3e 100644 --- a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py +++ b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_visibility.py @@ -18,6 +18,10 @@ def test_get_model(client): assert result == models.VisibilityModel(read_prop="abc") +def test_head_model(client): + assert client.head_model(models.VisibilityModel(), query_prop=123) + + def test_put_model(client): client.put_model(models.VisibilityModel(create_prop=["foo", "bar"], update_prop=[1, 2])) From 5a3b50eb506ced4eb62dbddf620a8c482841947e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 23:08:31 +0000 Subject: [PATCH 07/21] Initial plan From d812b34191ae380cc6365abbf1ad896089d16a5c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 23:15:03 +0000 Subject: [PATCH 08/21] test(python): add azure alternate-type mock api sync and async tests Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/3531a98a-0030-4de8-a9db-79f4da5836e6 Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...e-type-mock-api-test-2026-5-12-23-16-00.md | 7 +++ ...ent_generator_core_alternate_type_async.py | 55 +++++++++++++++++++ ...re_client_generator_core_alternate_type.py | 50 +++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py diff --git a/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md b/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md new file mode 100644 index 00000000000..e769fe03d94 --- /dev/null +++ b/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock API tests for the azure/client-generator-core/alternate-type Spector scenario. diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py new file mode 100644 index 00000000000..b741d5bad9e --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py @@ -0,0 +1,55 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import geojson +import pytest +import pytest_asyncio +from specs.azure.clientgenerator.core.alternatetype import aio, models + +FEATURE = geojson.Feature( + geometry=geojson.Point((-122.25, 37.87)), + properties={ + "name": "A single point of interest", + "category": "landmark", + "elevation": 100, + }, + id="feature-1", +) + + +@pytest_asyncio.fixture +async def client(): + async with aio.AlternateTypeClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_get_model(client: aio.AlternateTypeClient): + result = await client.external_type.get_model() + assert result == FEATURE + + +@pytest.mark.asyncio +async def test_put_model(client: aio.AlternateTypeClient): + await client.external_type.put_model(FEATURE) + + +@pytest.mark.asyncio +async def test_get_property(client: aio.AlternateTypeClient): + result = await client.external_type.get_property() + assert result == models.ModelWithFeatureProperty( + feature=FEATURE, + additional_property="extra", + ) + + +@pytest.mark.asyncio +async def test_put_property(client: aio.AlternateTypeClient): + await client.external_type.put_property( + models.ModelWithFeatureProperty( + feature=FEATURE, + additional_property="extra", + ) + ) diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py new file mode 100644 index 00000000000..47faf6332a8 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py @@ -0,0 +1,50 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import geojson +import pytest +from specs.azure.clientgenerator.core.alternatetype import AlternateTypeClient, models + +FEATURE = geojson.Feature( + geometry=geojson.Point((-122.25, 37.87)), + properties={ + "name": "A single point of interest", + "category": "landmark", + "elevation": 100, + }, + id="feature-1", +) + + +@pytest.fixture +def client(): + with AlternateTypeClient() as client: + yield client + + +def test_get_model(client: AlternateTypeClient): + result = client.external_type.get_model() + assert result == FEATURE + + +def test_put_model(client: AlternateTypeClient): + client.external_type.put_model(FEATURE) + + +def test_get_property(client: AlternateTypeClient): + result = client.external_type.get_property() + assert result == models.ModelWithFeatureProperty( + feature=FEATURE, + additional_property="extra", + ) + + +def test_put_property(client: AlternateTypeClient): + client.external_type.put_property( + models.ModelWithFeatureProperty( + feature=FEATURE, + additional_property="extra", + ) + ) From b0c8778a9b9c4c8df290638db3ce3a2641f5806b Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 14 May 2026 14:28:26 +0800 Subject: [PATCH 09/21] Update add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md --- ...dd-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md b/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md index e769fe03d94..47ce56ebe73 100644 --- a/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md +++ b/.chronus/changes/add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md @@ -4,4 +4,4 @@ packages: - "@typespec/http-client-python" --- -Add sync and async mock API tests for the azure/client-generator-core/alternate-type Spector scenario. +Add sync and async mock API tests for the azure/client-generator-core/alternate-type Spector scenario From d9a95a73396d0006966ad58fa77de006b58f1891 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 May 2026 23:16:03 +0000 Subject: [PATCH 10/21] Initial plan From c97ae05f0d3578cf2a8a67d582e7c8078b5fd63c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 May 2026 23:24:18 +0000 Subject: [PATCH 11/21] Add usage namespace mock API tests for python SDK Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...usage-namespace-test-2026-5-26-23-18-25.md | 7 +++++++ packages/http-client-python/package-lock.json | 8 ++++---- packages/http-client-python/package.json | 20 +++++++++---------- ...azure_client_generator_core_usage_async.py | 7 +++++++ .../test_azure_client_generator_core_usage.py | 6 ++++++ 5 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 .chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md diff --git a/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md b/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md new file mode 100644 index 00000000000..255a67569a5 --- /dev/null +++ b/.chronus/changes/python-usage-namespace-test-2026-5-26-23-18-25.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock API tests for the Azure client-generator-core usage namespace usage scenario from azure-http-specs. diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index cc9078bf7e4..10a7f975977 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -17,7 +17,7 @@ "tsx": "^4.21.0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.41-dev.1", + "@azure-tools/azure-http-specs": "^0.1.0-alpha.41-dev.2", "@azure-tools/typespec-autorest": "~0.68.0", "@azure-tools/typespec-azure-core": "~0.68.0", "@azure-tools/typespec-azure-resource-manager": "~0.68.0", @@ -66,9 +66,9 @@ } }, "node_modules/@azure-tools/azure-http-specs": { - "version": "0.1.0-alpha.41-dev.1", - "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.41-dev.1.tgz", - "integrity": "sha512-GaFmm7KP19YtxgdE2eyA37XusQCqoxo7UA6Lj9iLnXE77XPeDppE1pKstWFAbMcv/Jrc/EGqkl+TOGApej/JoA==", + "version": "0.1.0-alpha.41-dev.2", + "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.41-dev.2.tgz", + "integrity": "sha512-bx3thSgOwuLjqiYbyFal6d7q29Wo8lyNCVs8CIgoZzOievXM7dzJTfCI1RplPYydObcMeYAnAaPH32/YoFj93w==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index ef31a825df2..5146ccc8acc 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -66,13 +66,13 @@ "@azure-tools/typespec-azure-rulesets": ">=0.68.0 <1.0.0", "@azure-tools/typespec-client-generator-core": ">=0.68.0 <1.0.0", "@typespec/compiler": "^1.12.0", + "@typespec/events": ">=0.82.0 <1.0.0", "@typespec/http": "^1.12.0", "@typespec/openapi": "^1.12.0", "@typespec/rest": ">=0.82.0 <1.0.0", - "@typespec/versioning": ">=0.82.0 <1.0.0", - "@typespec/events": ">=0.82.0 <1.0.0", "@typespec/sse": ">=0.82.0 <1.0.0", "@typespec/streams": ">=0.82.0 <1.0.0", + "@typespec/versioning": ">=0.82.0 <1.0.0", "@typespec/xml": ">=0.82.0 <1.0.0" }, "playgroundConfig": { @@ -98,27 +98,27 @@ "tsx": "^4.21.0" }, "devDependencies": { + "@azure-tools/azure-http-specs": "^0.1.0-alpha.41-dev.2", "@azure-tools/typespec-autorest": "~0.68.0", "@azure-tools/typespec-azure-core": "~0.68.0", "@azure-tools/typespec-azure-resource-manager": "~0.68.0", "@azure-tools/typespec-azure-rulesets": "~0.68.0", "@azure-tools/typespec-client-generator-core": "~0.68.2", - "@azure-tools/azure-http-specs": "0.1.0-alpha.41-dev.1", + "@types/js-yaml": "~4.0.5", + "@types/node": "~25.0.2", + "@types/semver": "7.5.8", "@typespec/compiler": "^1.12.0", + "@typespec/events": "~0.82.0", "@typespec/http": "^1.12.0", + "@typespec/http-specs": "0.1.0-alpha.37", "@typespec/openapi": "^1.12.0", "@typespec/rest": "~0.82.0", - "@typespec/versioning": "~0.82.0", - "@typespec/events": "~0.82.0", - "@typespec/spector": "0.1.0-alpha.25", "@typespec/spec-api": "0.1.0-alpha.14", + "@typespec/spector": "0.1.0-alpha.25", "@typespec/sse": "~0.82.0", "@typespec/streams": "~0.82.0", + "@typespec/versioning": "~0.82.0", "@typespec/xml": "~0.82.0", - "@typespec/http-specs": "0.1.0-alpha.37", - "@types/js-yaml": "~4.0.5", - "@types/node": "~25.0.2", - "@types/semver": "7.5.8", "c8": "^10.1.3", "picocolors": "~1.1.1", "rimraf": "~6.1.2", diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py index 816279eeb94..f5c213c221d 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py @@ -37,3 +37,10 @@ async def test_orphan_model_serializable(client: UsageClient): await client.model_in_operation.orphan_model_serializable( body=models.OrphanModel(model_name="name", description="desc") ) + + +@pytest.mark.asyncio +async def test_namespace_model_serializable(client: UsageClient): + namespace_model = models.NamespaceModel(name="test") + assert isinstance(models.NestedNamespaceModel(value="test"), models.NestedNamespaceModel) + await client.namespace_usage.namespace_model_serializable(body=namespace_model) diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py index 0094bef89a1..e708b0a24b2 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py @@ -30,3 +30,9 @@ def test_model_usage(client: UsageClient): def test_orphan_model_serializable(client: UsageClient): client.model_in_operation.orphan_model_serializable(body=models.OrphanModel(model_name="name", description="desc")) + + +def test_namespace_model_serializable(client: UsageClient): + namespace_model = models.NamespaceModel(name="test") + assert isinstance(models.NestedNamespaceModel(value="test"), models.NestedNamespaceModel) + client.namespace_usage.namespace_model_serializable(body=namespace_model) From 495de8427f31706c5b7b201e194673d1ceadc580 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 May 2026 23:27:43 +0000 Subject: [PATCH 12/21] Refine usage namespace tests after review feedback Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../asynctests/test_azure_client_generator_core_usage_async.py | 1 - .../mock_api/azure/test_azure_client_generator_core_usage.py | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py index f5c213c221d..9a82c7e573a 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_usage_async.py @@ -42,5 +42,4 @@ async def test_orphan_model_serializable(client: UsageClient): @pytest.mark.asyncio async def test_namespace_model_serializable(client: UsageClient): namespace_model = models.NamespaceModel(name="test") - assert isinstance(models.NestedNamespaceModel(value="test"), models.NestedNamespaceModel) await client.namespace_usage.namespace_model_serializable(body=namespace_model) diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py index e708b0a24b2..4bc9b912324 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py @@ -34,5 +34,4 @@ def test_orphan_model_serializable(client: UsageClient): def test_namespace_model_serializable(client: UsageClient): namespace_model = models.NamespaceModel(name="test") - assert isinstance(models.NestedNamespaceModel(value="test"), models.NestedNamespaceModel) client.namespace_usage.namespace_model_serializable(body=namespace_model) From 30d4da5f07df6c19b459cad1886217d4d4191b3c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 09:32:14 +0000 Subject: [PATCH 13/21] refactor(http-client-python): remove unnecessary payload/head namespace override; add cls header test Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../http-client-python/eng/scripts/ci/regenerate-common.ts | 3 --- .../mock_api/shared/asynctests/test_payload_head_async.py | 7 +++++++ .../tests/mock_api/shared/test_payload_head.py | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 23ea765b877..1fe6f17d63c 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -197,9 +197,6 @@ export const AZURE_EMITTER_OPTIONS: Record< "payload/content-negotiation": { namespace: "payload.contentnegotiation", }, - "payload/head": { - namespace: "payload.head", - }, "payload/multipart": { namespace: "payload.multipart", }, diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py index 41a421c8fd7..0b24e996530 100644 --- a/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py @@ -17,3 +17,10 @@ async def client(): @pytest.mark.asyncio async def test_content_type_header_in_response(client: HeadClient): assert await client.content_type_header_in_response() is True + + +@pytest.mark.asyncio +async def test_content_type_header_in_response_with_cls(client: HeadClient): + headers = await client.content_type_header_in_response(cls=lambda x, y, z: z) + assert headers["Content-Type"] == "text/plain; charset=utf-8" + assert headers["x-ms-meta"] == "hello" diff --git a/packages/http-client-python/tests/mock_api/shared/test_payload_head.py b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py index e179d8d2c89..86464d56b2d 100644 --- a/packages/http-client-python/tests/mock_api/shared/test_payload_head.py +++ b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py @@ -15,3 +15,9 @@ def client(): def test_content_type_header_in_response(client: HeadClient): assert client.content_type_header_in_response() is True + + +def test_content_type_header_in_response_with_cls(client: HeadClient): + headers = client.content_type_header_in_response(cls=lambda x, y, z: z) + assert headers["Content-Type"] == "text/plain; charset=utf-8" + assert headers["x-ms-meta"] == "hello" From 0cc5124b3112add332eeaf66eb2e14be0d392e97 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 05:32:16 +0000 Subject: [PATCH 14/21] Initial plan From 6285c638e0e213623be3cb7736b9d44f9293643c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 05:39:29 +0000 Subject: [PATCH 15/21] test(http-client-python): add response-as-bool spector mock api test Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...-response-as-bool-test-2026-6-10-5-33-0.md | 7 ++++++ .../eng/scripts/ci/regenerate-common.ts | 1 - ...t_generator_core_response_as_bool_async.py | 24 +++++++++++++++++++ ..._client_generator_core_response_as_bool.py | 21 ++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py diff --git a/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md b/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md new file mode 100644 index 00000000000..9c5937cf445 --- /dev/null +++ b/.chronus/changes/python-add-response-as-bool-test-2026-6-10-5-33-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock api test for azure client-generator-core response-as-bool spector case diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 1fe6f17d63c..5ae8809eec8 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -73,7 +73,6 @@ export interface BuildTaskGroupsOptions { export const SKIP_SPECS: string[] = [ "type/file", "service/multiple-services", - "azure/client-generator-core/response-as-bool", ]; export const SpecialFlags: Record> = { diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py new file mode 100644 index 00000000000..9df21cc96d8 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_response_as_bool_async.py @@ -0,0 +1,24 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from specs.azure.clientgenerator.core.responseasbool.aio import ResponseAsBoolClient + + +@pytest_asyncio.fixture +async def client(): + async with ResponseAsBoolClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_exists(client: ResponseAsBoolClient): + assert await client.head_as_boolean.exists() is True + + +@pytest.mark.asyncio +async def test_not_exists(client: ResponseAsBoolClient): + assert await client.head_as_boolean.not_exists() is False diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py new file mode 100644 index 00000000000..e37a641ce11 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_response_as_bool.py @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from specs.azure.clientgenerator.core.responseasbool import ResponseAsBoolClient + + +@pytest.fixture +def client(): + with ResponseAsBoolClient() as client: + yield client + + +def test_exists(client: ResponseAsBoolClient): + assert client.head_as_boolean.exists() is True + + +def test_not_exists(client: ResponseAsBoolClient): + assert client.head_as_boolean.not_exists() is False From 9c19e8192697200c0787212625d3e859448c9a62 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 10 Jun 2026 15:11:13 +0800 Subject: [PATCH 16/21] update --- .../mock_api/azure/test_azure_client_generator_core_usage.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py index 4bc9b912324..f40f64041eb 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_usage.py @@ -35,3 +35,7 @@ def test_orphan_model_serializable(client: UsageClient): def test_namespace_model_serializable(client: UsageClient): namespace_model = models.NamespaceModel(name="test") client.namespace_usage.namespace_model_serializable(body=namespace_model) + +def test_import(): + # NestedNamespaceModel shall be exposed + from specs.azure.clientgenerator.core.usage.models import NestedNamespaceModel From 7aaeade7469e3a1c19cfc3d2490e90bab2669025 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 10 Jun 2026 15:15:58 +0800 Subject: [PATCH 17/21] update --- cspell.yaml | 1 + .../http-client-python/eng/scripts/ci/regenerate-common.ts | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cspell.yaml b/cspell.yaml index 58ec6e0489f..42cc56da89c 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -238,6 +238,7 @@ words: - reinjected - repr - respecify + - responseasbool - rjust - rollup - rpaas diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 5ae8809eec8..6e749675d09 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -70,10 +70,7 @@ export interface BuildTaskGroupsOptions { // ---- Public constants ---- -export const SKIP_SPECS: string[] = [ - "type/file", - "service/multiple-services", -]; +export const SKIP_SPECS: string[] = ["type/file", "service/multiple-services"]; export const SpecialFlags: Record> = { azure: { From ee892c6d5979dfdae43cb1cbb6bc84758ff43b5f Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 10 Jun 2026 15:20:41 +0800 Subject: [PATCH 18/21] update --- ...ent_generator_core_alternate_type_async.py | 78 +++++++++++------- ...re_client_generator_core_alternate_type.py | 79 ++++++++++++------- 2 files changed, 97 insertions(+), 60 deletions(-) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py index b741d5bad9e..589aca79600 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py @@ -3,53 +3,71 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import geojson import pytest -import pytest_asyncio -from specs.azure.clientgenerator.core.alternatetype import aio, models +import geojson +from specs.azure.clientgenerator.core.alternatetype.aio import AlternateTypeClient +from specs.azure.clientgenerator.core.alternatetype import models + +# Shared test data +PROPERTIES = {"name": "A single point of interest", "category": "landmark", "elevation": 100} -FEATURE = geojson.Feature( - geometry=geojson.Point((-122.25, 37.87)), - properties={ - "name": "A single point of interest", - "category": "landmark", - "elevation": 100, - }, - id="feature-1", -) +GEOMETRY = geojson.Point((-122.25, 37.87)) +FEATURE_ID = "feature-1" -@pytest_asyncio.fixture + +@pytest.fixture async def client(): - async with aio.AlternateTypeClient() as client: + async with AlternateTypeClient(endpoint="http://localhost:3000") as client: yield client +@pytest.fixture +def feature_geojson(): + """Shared GeoJSON Feature for tests.""" + return geojson.Feature(type="Feature", geometry=GEOMETRY, properties=PROPERTIES, id=FEATURE_ID) + + @pytest.mark.asyncio -async def test_get_model(client: aio.AlternateTypeClient): +async def test_external_type_get_model(client: AlternateTypeClient): + """Test getting a Feature object with geometry, properties, and optional id fields.""" result = await client.external_type.get_model() - assert result == FEATURE + + # Validate the response structure based on the TypeSpec example + assert result.type == "Feature" + assert result.geometry.type == "Point" + assert result.geometry.coordinates == [-122.25, 37.87] + assert result.properties == PROPERTIES + assert result.id == FEATURE_ID @pytest.mark.asyncio -async def test_put_model(client: aio.AlternateTypeClient): - await client.external_type.put_model(FEATURE) +async def test_external_type_put_model(client: AlternateTypeClient, feature_geojson): + """Test putting a Feature object in request body.""" + # Should return None (204/empty response) + result = await client.external_type.put_model(body=feature_geojson) + assert result is None @pytest.mark.asyncio -async def test_get_property(client: aio.AlternateTypeClient): +async def test_external_type_get_property(client: AlternateTypeClient): + """Test getting a ModelWithFeatureProperty object with feature and additionalProperty fields.""" result = await client.external_type.get_property() - assert result == models.ModelWithFeatureProperty( - feature=FEATURE, - additional_property="extra", - ) + + # Validate the response structure based on the TypeSpec example + assert result.feature.type == "Feature" + assert result.feature.geometry.type == "Point" + assert result.feature.geometry.coordinates == [-122.25, 37.87] + assert result.feature.properties == PROPERTIES + assert result.feature.id == FEATURE_ID + assert result.additional_property == "extra" @pytest.mark.asyncio -async def test_put_property(client: aio.AlternateTypeClient): - await client.external_type.put_property( - models.ModelWithFeatureProperty( - feature=FEATURE, - additional_property="extra", - ) - ) +async def test_external_type_put_property(client: AlternateTypeClient, feature_geojson): + """Test putting a ModelWithFeatureProperty object in request body.""" + model_with_feature = models.ModelWithFeatureProperty(feature=feature_geojson, additional_property="extra") + + # Should return None (204/empty response) + result = await client.external_type.put_property(body=model_with_feature) + assert result is None diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py index 47faf6332a8..c5ae3266c87 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_alternate_type.py @@ -3,48 +3,67 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import geojson import pytest -from specs.azure.clientgenerator.core.alternatetype import AlternateTypeClient, models +import geojson +from specs.azure.clientgenerator.core.alternatetype import AlternateTypeClient +from specs.azure.clientgenerator.core.alternatetype import models + +# Shared test data +PROPERTIES = {"name": "A single point of interest", "category": "landmark", "elevation": 100} -FEATURE = geojson.Feature( - geometry=geojson.Point((-122.25, 37.87)), - properties={ - "name": "A single point of interest", - "category": "landmark", - "elevation": 100, - }, - id="feature-1", -) +GEOMETRY = geojson.Point((-122.25, 37.87)) + +FEATURE_ID = "feature-1" @pytest.fixture def client(): - with AlternateTypeClient() as client: + with AlternateTypeClient(endpoint="http://localhost:3000") as client: yield client -def test_get_model(client: AlternateTypeClient): +@pytest.fixture +def feature_geojson(): + """Shared GeoJSON Feature for tests.""" + return geojson.Feature(type="Feature", geometry=GEOMETRY, properties=PROPERTIES, id=FEATURE_ID) + + +def test_external_type_get_model(client: AlternateTypeClient): + """Test getting a Feature object with geometry, properties, and optional id fields.""" result = client.external_type.get_model() - assert result == FEATURE + + # Validate the response structure based on the TypeSpec example + assert result.type == "Feature" + assert result.geometry.type == "Point" + assert result.geometry.coordinates == [-122.25, 37.87] + assert result.properties == PROPERTIES + assert result.id == FEATURE_ID -def test_put_model(client: AlternateTypeClient): - client.external_type.put_model(FEATURE) +def test_external_type_put_model(client: AlternateTypeClient, feature_geojson): + """Test putting a Feature object in request body.""" + # Should return None (204/empty response) + result = client.external_type.put_model(body=feature_geojson) + assert result is None -def test_get_property(client: AlternateTypeClient): +def test_external_type_get_property(client: AlternateTypeClient): + """Test getting a ModelWithFeatureProperty object with feature and additionalProperty fields.""" result = client.external_type.get_property() - assert result == models.ModelWithFeatureProperty( - feature=FEATURE, - additional_property="extra", - ) - - -def test_put_property(client: AlternateTypeClient): - client.external_type.put_property( - models.ModelWithFeatureProperty( - feature=FEATURE, - additional_property="extra", - ) - ) + + # Validate the response structure based on the TypeSpec example + assert result.feature.type == "Feature" + assert result.feature.geometry.type == "Point" + assert result.feature.geometry.coordinates == [-122.25, 37.87] + assert result.feature.properties == PROPERTIES + assert result.feature.id == FEATURE_ID + assert result.additional_property == "extra" + + +def test_external_type_put_property(client: AlternateTypeClient, feature_geojson): + """Test putting a ModelWithFeatureProperty object in request body.""" + model_with_feature = models.ModelWithFeatureProperty(feature=feature_geojson, additional_property="extra") + + # Should return None (204/empty response) + result = client.external_type.put_property(body=model_with_feature) + assert result is None From f6b02924062011ea8f98f598bf09efce55f18d31 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 10 Jun 2026 15:27:02 +0800 Subject: [PATCH 19/21] update regenerate-common --- packages/http-client-python/eng/scripts/ci/regenerate-common.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 6e749675d09..cdb9e67bfef 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -724,6 +724,7 @@ export async function prepareBaselineOfGeneratedCode(generatedFolder: string): P "azure/generation-subdir2", "unbranded/generation-subdir", "unbranded/generation-subdir2", + "azure-client-generator-core-alternate-type", ]; const sourceRoot = join(tempDir, ...sourceSubdir.split("/")); From 51727e57649b3895446db0af927385650fe996e9 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 10 Jun 2026 15:29:29 +0800 Subject: [PATCH 20/21] Update regenerate-common.ts --- packages/http-client-python/eng/scripts/ci/regenerate-common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index cdb9e67bfef..ded02b8ef50 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -724,7 +724,7 @@ export async function prepareBaselineOfGeneratedCode(generatedFolder: string): P "azure/generation-subdir2", "unbranded/generation-subdir", "unbranded/generation-subdir2", - "azure-client-generator-core-alternate-type", + "azure/azure-client-generator-core-alternate-type", ]; const sourceRoot = join(tempDir, ...sourceSubdir.split("/")); From 5783ece0cedccc1992c495517076724cf537b10e Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 10 Jun 2026 07:52:44 +0000 Subject: [PATCH 21/21] fix test case --- .../test_azure_client_generator_core_alternate_type_async.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py index 589aca79600..30f453723e1 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_alternate_type_async.py @@ -4,6 +4,7 @@ # license information. # -------------------------------------------------------------------------- import pytest +import pytest_asyncio import geojson from specs.azure.clientgenerator.core.alternatetype.aio import AlternateTypeClient from specs.azure.clientgenerator.core.alternatetype import models @@ -16,7 +17,7 @@ FEATURE_ID = "feature-1" -@pytest.fixture +@pytest_asyncio.fixture async def client(): async with AlternateTypeClient(endpoint="http://localhost:3000") as client: yield client