Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f603b3d
Initial plan
Copilot Apr 17, 2026
ee65d6b
feat(http-client-python): add mock API test for payload/head scenario
Copilot Apr 17, 2026
6ace066
Initial plan
Copilot Apr 28, 2026
789742f
feat(http-client-python): add test cases for reserved operation body …
Copilot Apr 28, 2026
7acec0c
Initial plan
Copilot May 4, 2026
0bb8ead
test(python): add test_head_model for type/model/visibility spec
Copilot May 4, 2026
5a3b50e
Initial plan
Copilot May 12, 2026
d812b34
test(python): add azure alternate-type mock api sync and async tests
Copilot May 12, 2026
a81b680
Merge branch 'main' into copilot/add-test-case-for-pull-4408
msyyc May 14, 2026
b0c8778
Update add-python-alternate-type-mock-api-test-2026-5-12-23-16-00.md
msyyc May 14, 2026
d9a95a7
Initial plan
Copilot May 26, 2026
c97ae05
Add usage namespace mock API tests for python SDK
Copilot May 26, 2026
495de84
Refine usage namespace tests after review feedback
Copilot May 26, 2026
a95e419
Merge branch 'main' into copilot/add-test-case-for-pull-10194
Copilot Jun 4, 2026
30d4da5
refactor(http-client-python): remove unnecessary payload/head namespa…
Copilot Jun 4, 2026
0cc5124
Initial plan
Copilot Jun 10, 2026
119ab0a
Merge branch 'main' into copilot/add-test-case-for-pull-10194
Copilot Jun 10, 2026
6285c63
test(http-client-python): add response-as-bool spector mock api test
Copilot Jun 10, 2026
8d15b62
Merge branch 'main' into copilot/add-test-case-for-pull-9884
msyyc Jun 10, 2026
bff32a3
Merge remote-tracking branch 'origin/main' into copilot/add-test-case…
Copilot Jun 10, 2026
99a29ca
Merge branch 'main' into copilot/add-test-case-for-pull-4408
msyyc Jun 10, 2026
5b80ea6
Merge branch 'main' into copilot/add-test-case-for-pr-4328
msyyc Jun 10, 2026
90dcf1c
Merge branch 'copilot/add-test-case-for-pull-10194' of https://github…
msyyc Jun 10, 2026
fa4f04e
Merge origin/main into copilot/add-test-case-for-pull-4493
Copilot Jun 10, 2026
a90bfb5
Merge branch 'copilot/add-test-case-for-pull-10529' of https://github…
msyyc Jun 10, 2026
ef4c862
Merge branch 'copilot/add-test-case-for-pull-9884' of https://github.…
msyyc Jun 10, 2026
a4d5d26
Merge branch 'copilot/add-test-case-for-pull-4493' of https://github.…
msyyc Jun 10, 2026
9c19e81
update
msyyc Jun 10, 2026
0b0d416
Merge branch 'copilot/add-test-case-for-pr-4328' of https://github.co…
msyyc Jun 10, 2026
7aaeade
update
msyyc Jun 10, 2026
fe66c7f
Merge branch 'copilot/add-test-case-for-pull-4408' of https://github.…
msyyc Jun 10, 2026
ee892c6
update
msyyc Jun 10, 2026
f6b0292
update regenerate-common
msyyc Jun 10, 2026
51727e5
Update regenerate-common.ts
msyyc Jun 10, 2026
5783ece
fix test case
msyyc Jun 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-python"
---

Add test coverage for `headModel` scenario in `type/model/visibility` spec.
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ words:
- reinjected
- repr
- respecify
- responseasbool
- rjust
- rollup
- rpaas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ export interface BuildTaskGroupsOptions {

// ---- Public constants ----

export const SKIP_SPECS: string[] = [
"type/file",
"service/multiple-services",
"azure/client-generator-core/response-as-bool",
];
export const SKIP_SPECS: string[] = ["type/file", "service/multiple-services"];

export const SpecialFlags: Record<string, Record<string, any>> = {
azure: {
Expand Down Expand Up @@ -728,6 +724,7 @@ export async function prepareBaselineOfGeneratedCode(generatedFolder: string): P
"azure/generation-subdir2",
"unbranded/generation-subdir",
"unbranded/generation-subdir2",
"azure/azure-client-generator-core-alternate-type",
];

const sourceRoot = join(tempDir, ...sourceSubdir.split("/"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# -------------------------------------------------------------------------
# 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
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}

GEOMETRY = geojson.Point((-122.25, 37.87))

FEATURE_ID = "feature-1"


@pytest_asyncio.fixture
async def 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_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()

# 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_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_external_type_get_property(client: AlternateTypeClient):
"""Test getting a ModelWithFeatureProperty object with feature and additionalProperty fields."""
result = await client.external_type.get_property()

# 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_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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ 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")
await client.namespace_usage.namespace_model_serializable(body=namespace_model)
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -------------------------------------------------------------------------
# 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 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}

GEOMETRY = geojson.Point((-122.25, 37.87))

FEATURE_ID = "feature-1"


@pytest.fixture
def client():
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)


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()

# 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_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_external_type_get_property(client: AlternateTypeClient):
"""Test getting a ModelWithFeatureProperty object with feature and additionalProperty fields."""
result = client.external_type.get_property()

# 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ 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")
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
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -------------------------------------------------------------------------
# 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


@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"
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -------------------------------------------------------------------------
# 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


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"
Original file line number Diff line number Diff line change
Expand Up @@ -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]))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Loading