From 4a772c91b13ed7959989335311790ab04b1220a4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 07:59:32 +0000 Subject: [PATCH 1/3] Initial plan From 1be112ef6a7d77802eff6f9859d8ae98dd933128 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 08:09:48 +0000 Subject: [PATCH 2/3] feat(python): add test cases for flatten-property read-only and unknown model scenarios Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...n-read-only-model-tests-2026-3-6-8-0-10.md | 7 ++++++ ...ure_client_generator_core_flatten_async.py | 23 +++++++++++++++++-- ...est_azure_client_generator_core_flatten.py | 21 +++++++++++++++-- packages/http-client-python/package-lock.json | 16 ++++++------- packages/http-client-python/package.json | 2 +- 5 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 .chronus/changes/add-flatten-read-only-model-tests-2026-3-6-8-0-10.md diff --git a/.chronus/changes/add-flatten-read-only-model-tests-2026-3-6-8-0-10.md b/.chronus/changes/add-flatten-read-only-model-tests-2026-3-6-8-0-10.md new file mode 100644 index 00000000000..e4bbcfb6773 --- /dev/null +++ b/.chronus/changes/add-flatten-read-only-model-tests-2026-3-6-8-0-10.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add test cases for flatten property with read-only properties (putFlattenReadOnlyModel and putFlattenUnknownModel scenarios). diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py index fe2f64f13db..608bb3df777 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py @@ -6,10 +6,13 @@ import pytest from specs.azure.clientgenerator.core.flattenproperty.aio import FlattenPropertyClient from specs.azure.clientgenerator.core.flattenproperty.models import ( - FlattenModel, + ChildFlattenModel, ChildModel, + FlattenModel, + FlattenUnknownModel, NestedFlattenModel, - ChildFlattenModel, + Solution, + SolutionProperties, ) @@ -46,6 +49,22 @@ async def test_put_nested_flatten_model(client: FlattenPropertyClient): ) +@pytest.mark.asyncio +async def test_put_flatten_unknown_model(client: FlattenPropertyClient): + result = await client.put_flatten_unknown_model(FlattenUnknownModel(name="foo")) + assert result.name == "test" + assert result.properties == {"key1": "value1", "key2": "value2"} + + +@pytest.mark.asyncio +async def test_put_flatten_read_only_model(client: FlattenPropertyClient): + result = await client.put_flatten_read_only_model(Solution(name="foo")) + assert result == Solution( + name="foo", + properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"), + ) + + @pytest.mark.asyncio # ============test for compatibility ============ async def test_dpg_model_common(): flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test")) diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py index b1492f524ad..87371b971dd 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py @@ -6,10 +6,13 @@ import pytest from specs.azure.clientgenerator.core.flattenproperty import FlattenPropertyClient from specs.azure.clientgenerator.core.flattenproperty.models import ( - FlattenModel, + ChildFlattenModel, ChildModel, + FlattenModel, + FlattenUnknownModel, NestedFlattenModel, - ChildFlattenModel, + Solution, + SolutionProperties, ) @@ -41,6 +44,20 @@ def test_put_nested_flatten_model(client: FlattenPropertyClient): ) +def test_put_flatten_unknown_model(client: FlattenPropertyClient): + result = client.put_flatten_unknown_model(FlattenUnknownModel(name="foo")) + assert result.name == "test" + assert result.properties == {"key1": "value1", "key2": "value2"} + + +def test_put_flatten_read_only_model(client: FlattenPropertyClient): + result = client.put_flatten_read_only_model(Solution(name="foo")) + assert result == Solution( + name="foo", + properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"), + ) + + # ============test for compatibility ============ def test_dpg_model_common(): flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test")) diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 8035b620851..f4a84d1c7c6 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.38-dev.2", + "@azure-tools/azure-http-specs": "0.1.0-alpha.38-dev.6", "@azure-tools/typespec-autorest": "~0.65.0", "@azure-tools/typespec-azure-core": "~0.65.0", "@azure-tools/typespec-azure-resource-manager": "~0.65.0", @@ -66,9 +66,9 @@ } }, "node_modules/@azure-tools/azure-http-specs": { - "version": "0.1.0-alpha.38-dev.2", - "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.38-dev.2.tgz", - "integrity": "sha512-rrxSHv70c5d9ZZQRN1xZ849/vzAFM7uHEkpjSNtKBBkx/6/2J2arSiltk4OP6xE/lqHPVPeANzbYQsL4b4wNZw==", + "version": "0.1.0-alpha.38-dev.6", + "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.38-dev.6.tgz", + "integrity": "sha512-MXjnMSArEM1+ADCmSrYDsOlTzL9bQWaVMtrTtOK8+2eAL87dZdfxiFuiPr9jWHYC8m8nIwLZ+h4dE7TSQR0KwQ==", "dev": true, "license": "MIT", "dependencies": { @@ -81,7 +81,7 @@ "peerDependencies": { "@azure-tools/typespec-azure-core": "^0.65.0 || >=0.66.0-dev <0.66.0", "@typespec/compiler": "^1.9.0", - "@typespec/http": "^1.9.0", + "@typespec/http": "^1.9.1", "@typespec/rest": "^0.79.0 || >=0.80.0-dev <0.80.0", "@typespec/versioning": "^0.79.0 || >=0.80.0-dev <0.80.0", "@typespec/xml": "^0.79.0 || >=0.80.0-dev <0.80.0" @@ -2473,9 +2473,9 @@ } }, "node_modules/@typespec/http": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.9.0.tgz", - "integrity": "sha512-JzlZZsgCo71f2KhWbf4BLOz5e+dVLj7gJJ4kvXvrmuG9QHoT41VaGPpCQamYgpZLMz2LQbsOtw34AmpovhuJSw==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.9.1.tgz", + "integrity": "sha512-agcwmbB/hK/o9KmM38UB8OGZwLgB17lJ7b4EjqYGpyshqcRMTESMRxnJIH7rRzUq4HJDTqal0tsb8z0K0zXuDg==", "dev": true, "license": "MIT", "engines": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 39b23f709d7..2752851f089 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -82,7 +82,7 @@ "@azure-tools/typespec-azure-resource-manager": "~0.65.0", "@azure-tools/typespec-azure-rulesets": "~0.65.0", "@azure-tools/typespec-client-generator-core": "~0.65.3", - "@azure-tools/azure-http-specs": "0.1.0-alpha.38-dev.2", + "@azure-tools/azure-http-specs": "0.1.0-alpha.38-dev.6", "@typespec/compiler": "^1.9.0", "@typespec/http": "^1.9.0", "@typespec/openapi": "^1.9.0", From 4231f87515b2878ae07831669302ccae4eb464a0 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 6 Mar 2026 08:46:19 +0000 Subject: [PATCH 3/3] Sync flatten async tests with sync assertions --- .../test_azure_client_generator_core_flatten_async.py | 3 +++ .../mock_api_tests/test_azure_client_generator_core_flatten.py | 3 +++ .../generator/test/unittests/test_name_converter.py | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py index 608bb3df777..cb044b430fe 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py @@ -63,6 +63,9 @@ async def test_put_flatten_read_only_model(client: FlattenPropertyClient): name="foo", properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"), ) + assert result.solution_id == "solution1" + assert result.title == "Solution Title" + assert result.content == "Solution Content" @pytest.mark.asyncio # ============test for compatibility ============ diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py index 87371b971dd..30745aae253 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py @@ -56,6 +56,9 @@ def test_put_flatten_read_only_model(client: FlattenPropertyClient): name="foo", properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"), ) + assert result.solution_id == "solution1" + assert result.title == "Solution Title" + assert result.content == "Solution Content" # ============test for compatibility ============ diff --git a/packages/http-client-python/generator/test/unittests/test_name_converter.py b/packages/http-client-python/generator/test/unittests/test_name_converter.py index 4bfbee891b6..88a10a20409 100644 --- a/packages/http-client-python/generator/test/unittests/test_name_converter.py +++ b/packages/http-client-python/generator/test/unittests/test_name_converter.py @@ -33,4 +33,3 @@ def test_escaped_reserved_words(): } for name in expected_conversion_parameter: assert pad_reserved_words(name, pad_type=PadType.PARAMETER) == expected_conversion_parameter[name] -