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/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..0b24e996530 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_payload_head_async.py @@ -0,0 +1,26 @@ +# ------------------------------------------------------------------------- +# 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 + + +@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 new file mode 100644 index 00000000000..86464d56b2d --- /dev/null +++ b/packages/http-client-python/tests/mock_api/shared/test_payload_head.py @@ -0,0 +1,23 @@ +# ------------------------------------------------------------------------- +# 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 + + +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"