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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-python"
---

Add mock API tests for client response replacement.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export const AZURE_EMITTER_OPTIONS: Record<
"azure/client-generator-core/override": {
namespace: "specs.azure.clientgenerator.core.override",
},
"azure/client-generator-core/response-replacement": {
namespace: "specs.azure.clientgenerator.core.responsereplacement",
},
"azure/client-generator-core/hierarchy-building": {
namespace: "specs.azure.clientgenerator.core.hierarchybuilding",
},
Expand Down
10 changes: 5 additions & 5 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.

2 changes: 1 addition & 1 deletion packages/http-client-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@azure-tools/typespec-azure-resource-manager": "~0.72.0",
"@azure-tools/typespec-azure-rulesets": "~0.72.0",
"@azure-tools/typespec-client-generator-core": "~0.72.1",
"@azure-tools/azure-http-specs": "0.1.0-alpha.45",
"@azure-tools/azure-http-specs": "0.1.0-alpha.46-dev.2",
"@typespec/compiler": "^1.16.0",
"@typespec/http": "^1.16.0",
"@typespec/openapi": "^1.16.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -------------------------------------------------------------------------
# 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.responsereplacement.aio import ResponseReplacementClient
from specs.azure.clientgenerator.core.responsereplacement.models import Widget


@pytest_asyncio.fixture
async def client():

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.

Copilot add "namespace" configuration in https://github.com/microsoft/typespec/blob/main/packages/http-client-python/eng/scripts/ci/regenerate-common.ts to keep consistent with other similar test cases then update test files.

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.

Added the response-replacement namespace override and updated both test imports in d910354c.

async with ResponseReplacementClient() as client:
yield client


@pytest.mark.asyncio
async def test_void_response(client: ResponseReplacementClient):
assert await client.void_response() == Widget(name="widget")


@pytest.mark.asyncio
async def test_bytes_response(client: ResponseReplacementClient):
assert await client.bytes_response() == Widget(name="widget")
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -------------------------------------------------------------------------
# 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.responsereplacement import ResponseReplacementClient
from specs.azure.clientgenerator.core.responsereplacement.models import Widget


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


def test_void_response(client: ResponseReplacementClient):
assert client.void_response() == Widget(name="widget")


def test_bytes_response(client: ResponseReplacementClient):
assert client.bytes_response() == Widget(name="widget")