From 729426cc5fda24746253a3a55ba8fa7252255b62 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 03:07:09 +0000 Subject: [PATCH 1/6] Initial plan From e2d5ce84ec8e1624872d9e909f8f66f51a915eed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 03:12:37 +0000 Subject: [PATCH 2/6] test(python): cover body-or-no-content Spector responses Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...se-body-or-no-content-2026-10-12-3-14-0.md | 7 ++++ .../test_response_body_or_no_content_async.py | 37 +++++++++++++++++++ .../test_response_body_or_no_content.py | 34 +++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md create mode 100644 packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py create mode 100644 packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py diff --git a/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md b/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md new file mode 100644 index 00000000000..3aa81d6331b --- /dev/null +++ b/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async Spector tests for responses with a model body or no content, including raw response status and headers. diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py new file mode 100644 index 00000000000..9894c83b704 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------- +# 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 response.bodyornocontent.aio import BodyOrNoContentClient +from response.bodyornocontent.models import BlobLayout + + +@pytest_asyncio.fixture +async def client(): + async with BodyOrNoContentClient(endpoint="http://localhost:3000") as client: + yield client + + +@pytest.mark.asyncio +async def test_get_body(client: BodyOrNoContentClient): + result, response = await client.get_body( + cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) + ) + + assert result == BlobLayout(content="hello") + assert response.status_code == 200 + assert response.headers["x-ms-request-id"] == "body-request" + + +@pytest.mark.asyncio +async def test_get_no_content(client: BodyOrNoContentClient): + result, response = await client.get_no_content( + cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) + ) + + assert result is None + assert response.status_code == 204 + assert response.headers["x-ms-request-id"] == "no-content-request" diff --git a/packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py b/packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py new file mode 100644 index 00000000000..f6e50bfde47 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py @@ -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 +from response.bodyornocontent import BodyOrNoContentClient +from response.bodyornocontent.models import BlobLayout + + +@pytest.fixture +def client(): + with BodyOrNoContentClient(endpoint="http://localhost:3000") as client: + yield client + + +def test_get_body(client: BodyOrNoContentClient): + result, response = client.get_body( + cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) + ) + + assert result == BlobLayout(content="hello") + assert response.status_code == 200 + assert response.headers["x-ms-request-id"] == "body-request" + + +def test_get_no_content(client: BodyOrNoContentClient): + result, response = client.get_no_content( + cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) + ) + + assert result is None + assert response.status_code == 204 + assert response.headers["x-ms-request-id"] == "no-content-request" From 9811c2f3b83dacbd7ab9687a68be6d8d2af8cb2c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 05:32:24 +0000 Subject: [PATCH 3/6] test(python): assert default body-or-no-content return values Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../test_response_body_or_no_content_async.py | 14 ++++++-------- .../shared/test_response_body_or_no_content.py | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py index 9894c83b704..ce1608e9890 100644 --- a/packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_response_body_or_no_content_async.py @@ -17,21 +17,19 @@ async def client(): @pytest.mark.asyncio async def test_get_body(client: BodyOrNoContentClient): - result, response = await client.get_body( - cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) - ) - + result = await client.get_body() assert result == BlobLayout(content="hello") + + response = await client.get_body(cls=lambda pipeline_response, _, __: pipeline_response.http_response) assert response.status_code == 200 assert response.headers["x-ms-request-id"] == "body-request" @pytest.mark.asyncio async def test_get_no_content(client: BodyOrNoContentClient): - result, response = await client.get_no_content( - cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) - ) - + result = await client.get_no_content() assert result is None + + response = await client.get_no_content(cls=lambda pipeline_response, _, __: pipeline_response.http_response) assert response.status_code == 204 assert response.headers["x-ms-request-id"] == "no-content-request" diff --git a/packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py b/packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py index f6e50bfde47..38c76ffaeaf 100644 --- a/packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py +++ b/packages/http-client-python/tests/mock_api/shared/test_response_body_or_no_content.py @@ -15,20 +15,18 @@ def client(): def test_get_body(client: BodyOrNoContentClient): - result, response = client.get_body( - cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) - ) - + result = client.get_body() assert result == BlobLayout(content="hello") + + response = client.get_body(cls=lambda pipeline_response, _, __: pipeline_response.http_response) assert response.status_code == 200 assert response.headers["x-ms-request-id"] == "body-request" def test_get_no_content(client: BodyOrNoContentClient): - result, response = client.get_no_content( - cls=lambda pipeline_response, result, _: (result, pipeline_response.http_response) - ) - + result = client.get_no_content() assert result is None + + response = client.get_no_content(cls=lambda pipeline_response, _, __: pipeline_response.http_response) assert response.status_code == 204 assert response.headers["x-ms-request-id"] == "no-content-request" From 1cced2792bccc1efff360e68d4ea0b92a1ac3ad8 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 12 Oct 2026 14:01:09 +0800 Subject: [PATCH 4/6] Update python-response-body-or-no-content-2026-10-12-3-14-0.md --- .../python-response-body-or-no-content-2026-10-12-3-14-0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md b/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md index 3aa81d6331b..a869799273c 100644 --- a/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md +++ b/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md @@ -4,4 +4,4 @@ packages: - "@typespec/http-client-python" --- -Add sync and async Spector tests for responses with a model body or no content, including raw response status and headers. +Add sync and async Spector tests for responses with a model body or no content, including raw response status and headers From 1a261ab1b5f8949415e3b5671021e39f5057a2df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 06:16:44 +0000 Subject: [PATCH 5/6] chore: allow generated Python bodyornocontent module in spellcheck Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- cspell.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.yaml b/cspell.yaml index e16c4c437b1..328c0f73b33 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -40,6 +40,7 @@ words: - blib - blockful - blockless + - bodyornocontent - buongiorno - cadl - cadleditor From d2d71698e4a65152d45ba824b2c3362a2394a336 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 12 Oct 2026 15:11:21 +0800 Subject: [PATCH 6/6] Update python-response-body-or-no-content-2026-10-12-3-14-0.md --- .../python-response-body-or-no-content-2026-10-12-3-14-0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md b/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md index a869799273c..3aa81d6331b 100644 --- a/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md +++ b/.chronus/changes/python-response-body-or-no-content-2026-10-12-3-14-0.md @@ -4,4 +4,4 @@ packages: - "@typespec/http-client-python" --- -Add sync and async Spector tests for responses with a model body or no content, including raw response status and headers +Add sync and async Spector tests for responses with a model body or no content, including raw response status and headers.