From aa89decbf95796e26b14f6d5c96ef4cd7b213dd7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 06:33:15 +0000 Subject: [PATCH 1/2] Initial plan From bc113bc298400d8cb3788936a1272d75782dea60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 06:40:35 +0000 Subject: [PATCH 2/2] [python] add mock API tests for Azure.SpecialHeaders.ConditionalRequest Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...ditional-request-tests-2026-5-25-6-40-0.md | 7 ++++ ...ecial_headers_conditional_request_async.py | 36 +++++++++++++++++++ ...ure_special_headers_conditional_request.py | 31 ++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 .chronus/changes/python-conditional-request-tests-2026-5-25-6-40-0.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_special_headers_conditional_request_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_special_headers_conditional_request.py diff --git a/.chronus/changes/python-conditional-request-tests-2026-5-25-6-40-0.md b/.chronus/changes/python-conditional-request-tests-2026-5-25-6-40-0.md new file mode 100644 index 00000000000..5efa585d91c --- /dev/null +++ b/.chronus/changes/python-conditional-request-tests-2026-5-25-6-40-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API tests for `Azure.SpecialHeaders.ConditionalRequest` (eTag with standard and non-standard wire names). diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_special_headers_conditional_request_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_special_headers_conditional_request_async.py new file mode 100644 index 00000000000..264cc71cdb3 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_special_headers_conditional_request_async.py @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------- +# 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 azure.core import MatchConditions +from azure.specialheaders.conditionalrequest.aio import ConditionalRequestClient + + +@pytest_asyncio.fixture +async def client(): + async with ConditionalRequestClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_post_if_match(client: ConditionalRequestClient): + await client.post_if_match(etag="valid", match_condition=MatchConditions.IfNotModified) + + +@pytest.mark.asyncio +async def test_post_if_none_match(client: ConditionalRequestClient): + await client.post_if_none_match(etag="invalid", match_condition=MatchConditions.IfModified) + + +@pytest.mark.asyncio +async def test_post_custom_if_match(client: ConditionalRequestClient): + await client.post_custom_if_match(etag="valid", match_condition=MatchConditions.IfNotModified) + + +@pytest.mark.asyncio +async def test_post_custom_if_none_match(client: ConditionalRequestClient): + await client.post_custom_if_none_match(etag="invalid", match_condition=MatchConditions.IfModified) diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_special_headers_conditional_request.py b/packages/http-client-python/tests/mock_api/azure/test_azure_special_headers_conditional_request.py new file mode 100644 index 00000000000..dacd7ba07f0 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_special_headers_conditional_request.py @@ -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 azure.core import MatchConditions +from azure.specialheaders.conditionalrequest import ConditionalRequestClient + + +@pytest.fixture +def client(): + with ConditionalRequestClient() as client: + yield client + + +def test_post_if_match(client: ConditionalRequestClient): + client.post_if_match(etag="valid", match_condition=MatchConditions.IfNotModified) + + +def test_post_if_none_match(client: ConditionalRequestClient): + client.post_if_none_match(etag="invalid", match_condition=MatchConditions.IfModified) + + +def test_post_custom_if_match(client: ConditionalRequestClient): + client.post_custom_if_match(etag="valid", match_condition=MatchConditions.IfNotModified) + + +def test_post_custom_if_none_match(client: ConditionalRequestClient): + client.post_custom_if_none_match(etag="invalid", match_condition=MatchConditions.IfModified)