Skip to content

[python] Add test cases for flatten-property unknown type and read-only scenarios#9851

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-for-pull-3729
Draft

[python] Add test cases for flatten-property unknown type and read-only scenarios#9851
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-for-pull-3729

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Adds Python mock API tests covering two new Spector scenarios from Azure/typespec-azure#3729 for @flattenProperty edge cases.

Spec dependency bump

  • @azure-tools/azure-http-specs: 0.1.0-alpha.38-dev.20.1.0-alpha.38-dev.4 (adds the two new scenarios)

New test cases (sync + async)

putFlattenUnknownModel — flatten is a no-op on unknown type; properties stays as a top-level field:

def test_put_flatten_unknown_model(client):
    result = client.put_flatten_unknown_model(FlattenUnknownModel(name="foo"))
    assert result.name == "test"
    assert result.properties == {"key1": "value1", "key2": "value2"}

putFlattenReadOnlyModel — model whose flattened sub-object contains only read-only properties; uses the mapping constructor Solution({"name": "foo"}) so the empty properties bag is not serialized into the request body, matching the server's expected {"name": "foo"}. Read-only response fields are asserted via dict access since the generator stores them at the top level of the raw dict:

def test_put_flatten_read_only_model(client):
    result = client.put_flatten_read_only_model(Solution({"name": "foo"}))
    assert result.name == "foo"
    assert result["solutionId"] == "solution1"
    assert result["title"] == "Solution Title"
    assert result["content"] == "Solution Content"
Original prompt

This section details on the original issue you should resolve

<issue_title>[python] add test case for Azure/typespec-azure#3729</issue_title>
<issue_description>follow skill https://github.com/microsoft/typespec/blob/main/.github/skills/python-sdk-spector-mock-api-tests/SKILL.md to write test case for Azure/typespec-azure#3729</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…-only properties

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 Mar 2, 2026
Copilot AI changed the title [WIP] Add test case for Azure typespec-azure pull request 3729 [python] Add test cases for flatten-property unknown type and read-only scenarios Mar 2, 2026
Copilot finished work on behalf of msyyc March 2, 2026 07:38
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/3729

2 participants