Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-python"
---

Add test for the `@clientDoc` decorator spector case (azure/client-generator-core/client-doc).
4 changes: 2 additions & 2 deletions packages/http-client-python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -------------------------------------------------------------------------
# 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.clientdoc.aio import ClientDocClient
from specs.azure.clientgenerator.core.clientdoc import models


@pytest_asyncio.fixture
async def client():
async with ClientDocClient() as client:
yield client


@pytest.mark.asyncio
async def test_harvest(client: ClientDocClient):
body = models.Plant(name="Rose", species="Rosa")
assert await 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 "A plant in the garden." in models.Plant.__doc__
assert "This model is used to represent a plant in the client SDK." in models.Plant.__doc__


@pytest.mark.asyncio
async def test_operation_doc_replaced(client: ClientDocClient):
# @clientDoc in replace mode overrides the base @doc completely.
assert "Retrieves a plant from the garden by submitting its name." in client.documentation.harvest.__doc__
assert "Internal operation to get a plant." not in client.documentation.harvest.__doc__
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -------------------------------------------------------------------------
# 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.clientdoc import ClientDocClient
from specs.azure.clientgenerator.core.clientdoc import models


@pytest.fixture
def client():
with ClientDocClient() as client:
yield client


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 "A plant in the garden." in models.Plant.__doc__
assert "This model is used to represent a plant in the client SDK." in models.Plant.__doc__


def test_operation_doc_replaced(client: ClientDocClient):
# @clientDoc in replace mode overrides the base @doc completely.
assert "Retrieves a plant from the garden by submitting its name." in client.documentation.harvest.__doc__
assert "Internal operation to get a plant." not in client.documentation.harvest.__doc__
Loading