Skip to content
Merged
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 `Azure.SpecialHeaders.ConditionalRequest` (eTag with standard and non-standard wire names).
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Loading