Skip to content

[python] Add mock_api tests for exact() client name - #10792

Merged
Yuchao Yan (msyyc) merged 4 commits into
mainfrom
copilot/add-test-case-for-pull-4430
May 26, 2026
Merged

Yuchao Yan (msyyc) merged 4 commits into
mainfrom
copilot/add-test-case-for-pull-4430

Conversation

Copilot AI commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Covers the two new Spector scenarios from Azure/typespec-azure#4430, which verify that exact() used with @clientName skips language-specific casing transforms.

Dependency bumps (packages/http-client-python/package.json)

  • @azure-tools/azure-http-specs: 0.1.0-alpha.40 → 0.1.0-alpha.41-dev.1 (first version containing the exact-name spec).
  • @azure-tools/typespec-client-generator-core devDep: ~0.68.0 → ~0.68.2.

Tests

Added sync + async mock_api tests under tests/mock_api/azure/ for the ExactName client:

  • test_model / test_property: round-trip the POST /azure/client-generator-core/exact-name/{model,property} endpoints.
  • test_model_class_name_preserved: asserts the generated model class is My_model (not MyModel), confirming exact("my_model") bypasses PascalCasing.
  • test_property_name_preserved: asserts ScopedModel exposes attribute _my_name, confirming the python-scoped exact("_my_name") retains the leading underscore.
from specs.azure.clientgenerator.core.exactname import ExactNameClient
from specs.azure.clientgenerator.core.exactname.model.models import My_model
from specs.azure.clientgenerator.core.exactname.property.models import ScopedModel

with ExactNameClient() as client:
    assert client.model.send(body=My_model(name="test")).name == "test"
    assert client.property.send(body=ScopedModel({"name": "test"}))._my_name == "test"

assert My_model.__name__ == "My_model"
assert "_my_name" in ScopedModel.__annotations__

Note: ScopedModel(_my_name=...) kwarg init is not supported because the generated model base filters underscore-prefixed names out of _attr_to_rest_field; tests use dict-form init instead. May be worth a follow-up on the emitter side.

Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label May 26, 2026
Copilot AI changed the title [WIP] Add test case for pull 4430 and bump dependencies [python] Add mock_api tests for exact() client name May 26, 2026
Copilot AI requested a review from Yuchao Yan (msyyc) May 26, 2026 06:19
@msyyc
Yuchao Yan (msyyc) marked this pull request as ready for review May 26, 2026 06:32
@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@pkg-pr-new

pkg-pr-new Bot commented May 26, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@10792

commit: bb90a74

@github-actions

github-actions Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-python
Show changes

@typespec/http-client-python - internal ✏️

Add mock_api tests for the exact() function used with @clientName to preserve exact naming.

@msyyc
Yuchao Yan (msyyc) added this pull request to the merge queue May 26, 2026
Merged via the queue into main with commit a39c08a May 26, 2026
36 checks passed
@msyyc
Yuchao Yan (msyyc) deleted the copilot/add-test-case-for-pull-4430 branch May 26, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python] add test case for https://github.com/Azure/typespec-azure/pull/4430

3 participants