Skip to content

[python] Add test for client-doc spector scenario (Azure typespec-azure #4268)#10888

Draft
Copilot wants to merge 6 commits into
mainfrom
copilot/add-test-case-for-pull-4268
Draft

[python] Add test for client-doc spector scenario (Azure typespec-azure #4268)#10888
Copilot wants to merge 6 commits into
mainfrom
copilot/add-test-case-for-pull-4268

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Adds python SDK mock_api coverage for the spector cases introduced in Azure/typespec-azure#4268. Of the two new scenarios under azure/client-generator-core/, only client-doc is generatable by the python emitter (response-as-bool is already in SKIP_SPECS).

Changes

  • Tests — sync + async tests for the @clientDoc scenario:
    • harvest POST round-trip against the mock server.
    • @clientDoc append mode: Plant model docstring retains base doc and appends client-specific text.
    • @clientDoc replace mode: harvest operation docstring fully overrides the base doc.
    • Docstring assertions compare the whole docstring exactly (==) rather than substrings.
  • Changeloginternal chronus entry for @typespec/http-client-python.

response-as-bool is intentionally skipped in the emitter regeneration config, so no client is generated and no test is added for it.

def test_harvest(client: ClientDocClient):
    body = models.Plant(name="Rose", species="Rosa")
    assert client.documentation.harvest(body) == body

def test_model_doc_appended():
    # @clientDoc in append mode keeps the base @doc and appends the client-specific text.
    assert models.Plant.__doc__ == (
        "A plant in the garden. This model is used to represent a plant in the client SDK.\n"
        "\n"
        "    :ivar name: The name of the plant. Required.\n"
        "    :vartype name: str\n"
        "    :ivar species: The species of the plant. Required.\n"
        "    :vartype species: str\n"
        "    "
    )

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 Jun 4, 2026
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test case for Azure typespec pull request 4268 [python] Add test for client-doc spector scenario (Azure typespec-azure #4268) Jun 4, 2026
Copilot finished work on behalf of msyyc June 4, 2026 09:19
Copilot AI requested a review from msyyc June 4, 2026 09:19
assert client.documentation.harvest(body) == body


def test_model_doc_appended():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of check sub string, we should compare whole docstring with for all the test cases @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all the docstring assertions to compare the whole docstring with == instead of substring checks, for both sync and async tests. add5d5e

@msyyc

msyyc commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Copilot AI and others added 2 commits June 9, 2026 09:31
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
…-for-pull-4268

# Conflicts:
#	packages/http-client-python/package-lock.json

Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts with main. The only conflict was the version bump in packages/http-client-python/package-lock.json, which I aligned to 0.31.0 to match package.json. Merged in commit 3e6e6b8.

Copilot finished work on behalf of msyyc June 9, 2026 09:37
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/4268

2 participants