From f603b3deafc97db9715f185388f82a3b8a364746 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:49:54 +0000 Subject: [PATCH 1/3] Initial plan From ee65d6b7d3467b5833e2d21da43440b1fe0d7e1c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:56:09 +0000 Subject: [PATCH 2/3] feat(http-client-python): add mock API test for payload/head scenario Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/6b24cfbf-9b6f-4272-afae-99bea1b0548c Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...oad-head-python-test-2026-4-17-22-55-53.md | 7 ++++++ .../eng/scripts/ci/regenerate-common.ts | 3 +++ packages/http-client-python/package-lock.json | 25 +++++++++---------- packages/http-client-python/package.json | 2 +- .../asynctests/test_payload_head_async.py | 19 ++++++++++++++ .../mock_api/shared/test_payload_head.py | 17 +++++++++++++ 6 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 .chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md create mode 100644 packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py create mode 100644 packages/http-client-python/tests/mock_api/shared/test_payload_head.py diff --git a/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md b/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md new file mode 100644 index 00000000000..ee198e709bd --- /dev/null +++ b/.chronus/changes/payload-head-python-test-2026-4-17-22-55-53.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test for `payload/head` scenario with `Content-Type` and `x-ms-meta` response headers. diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index f54fe034663..1660e263a14 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -123,6 +123,9 @@ export const BASE_AZURE_EMITTER_OPTIONS: Record< "payload/content-negotiation": { namespace: "payload.contentnegotiation", }, + "payload/head": { + namespace: "payload.head", + }, "payload/multipart": { namespace: "payload.multipart", }, diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index a6129262122..0f1ae596b23 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.11.0", "@typespec/events": "~0.81.0", "@typespec/http": "^1.11.0", - "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/http-specs": "0.1.0-alpha.37-dev.3", "@typespec/openapi": "^1.11.0", "@typespec/rest": "~0.81.0", "@typespec/spec-api": "0.1.0-alpha.14", @@ -2520,25 +2520,24 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.36", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.36.tgz", - "integrity": "sha512-2nwh4YIx7MIwkVV8pZWUgp9dgR9U937MANtJvVILcWLLaBTVfLPXNQZjzDccFozzk8QxL7dBWA/gm7i6lsHZcA==", + "version": "0.1.0-alpha.37-dev.3", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.37-dev.3.tgz", + "integrity": "sha512-CJdJKxFd4XI77kmCRBGMuhIcq8M5CvduyFFixA51FTzVcHrM1RXe9L6CUSNDc/JJe/3TLeSEbntrAOqWOxVyDA==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14", - "@typespec/spector": "^0.1.0-alpha.25", - "deep-equal": "^2.2.3" + "@typespec/spec-api": "^0.1.0-alpha.14 || >= 0.1.0-dev.3", + "@typespec/spector": "^0.1.0-alpha.25 || >= 0.1.0-dev.4" }, "engines": { - "node": ">=16.0.0" + "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.11.0", - "@typespec/http": "^1.11.0", - "@typespec/rest": "^0.81.0", - "@typespec/versioning": "^0.81.0", - "@typespec/xml": "^0.81.0" + "@typespec/compiler": "^1.11.0 || >= 1.12.0-dev.4", + "@typespec/http": "^1.11.0 || >= 1.12.0-dev.2", + "@typespec/rest": "^0.81.0 || >= 0.82.0-dev.2", + "@typespec/versioning": "^0.81.0 || >= 0.82.0-dev.2", + "@typespec/xml": "^0.81.0 || >= 0.82.0-dev.2" } }, "node_modules/@typespec/openapi": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 1b911555093..750d898e322 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -115,7 +115,7 @@ "@typespec/sse": "~0.81.0", "@typespec/streams": "~0.81.0", "@typespec/xml": "~0.81.0", - "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/http-specs": "0.1.0-alpha.37-dev.3", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py new file mode 100644 index 00000000000..41a421c8fd7 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py @@ -0,0 +1,19 @@ +# ------------------------------------------------------------------------- +# 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 payload.head.aio import HeadClient + + +@pytest_asyncio.fixture +async def client(): + async with HeadClient(endpoint="http://localhost:3000") as client: + yield client + + +@pytest.mark.asyncio +async def test_content_type_header_in_response(client: HeadClient): + assert await client.content_type_header_in_response() is True diff --git a/packages/http-client-python/tests/mock_api/shared/test_payload_head.py b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py new file mode 100644 index 00000000000..e179d8d2c89 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------- +# 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 payload.head import HeadClient + + +@pytest.fixture +def client(): + with HeadClient(endpoint="http://localhost:3000") as client: + yield client + + +def test_content_type_header_in_response(client: HeadClient): + assert client.content_type_header_in_response() is True From 30d4da5f07df6c19b459cad1886217d4d4191b3c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 09:32:14 +0000 Subject: [PATCH 3/3] refactor(http-client-python): remove unnecessary payload/head namespace override; add cls header test Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../http-client-python/eng/scripts/ci/regenerate-common.ts | 3 --- .../mock_api/shared/asynctests/test_payload_head_async.py | 7 +++++++ .../tests/mock_api/shared/test_payload_head.py | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 23ea765b877..1fe6f17d63c 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -197,9 +197,6 @@ export const AZURE_EMITTER_OPTIONS: Record< "payload/content-negotiation": { namespace: "payload.contentnegotiation", }, - "payload/head": { - namespace: "payload.head", - }, "payload/multipart": { namespace: "payload.multipart", }, diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py index 41a421c8fd7..0b24e996530 100644 --- a/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py @@ -17,3 +17,10 @@ async def client(): @pytest.mark.asyncio async def test_content_type_header_in_response(client: HeadClient): assert await client.content_type_header_in_response() is True + + +@pytest.mark.asyncio +async def test_content_type_header_in_response_with_cls(client: HeadClient): + headers = await client.content_type_header_in_response(cls=lambda x, y, z: z) + assert headers["Content-Type"] == "text/plain; charset=utf-8" + assert headers["x-ms-meta"] == "hello" diff --git a/packages/http-client-python/tests/mock_api/shared/test_payload_head.py b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py index e179d8d2c89..86464d56b2d 100644 --- a/packages/http-client-python/tests/mock_api/shared/test_payload_head.py +++ b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py @@ -15,3 +15,9 @@ def client(): def test_content_type_header_in_response(client: HeadClient): assert client.content_type_header_in_response() is True + + +def test_content_type_header_in_response_with_cls(client: HeadClient): + headers = client.content_type_header_in_response(cls=lambda x, y, z: z) + assert headers["Content-Type"] == "text/plain; charset=utf-8" + assert headers["x-ms-meta"] == "hello"