Skip to content
Draft
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 sync and async mock API coverage for body-or-no-content responses.
26 changes: 13 additions & 13 deletions packages/http-client-python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/http-client-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"@typespec/sse": "~0.85.0",
"@typespec/streams": "~0.85.0",
"@typespec/xml": "~0.85.0",
"@typespec/http-specs": "0.1.0-alpha.41",
"@typespec/http-specs": "0.1.0-alpha.42-dev.1",
"@types/js-yaml": "~4.0.5",
"@types/node": "~25.0.2",
"@types/semver": "7.5.8",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -------------------------------------------------------------------------
# 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


@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):
body, response = await client.get_body(cls=lambda x, y, z: (y, x))

assert body.content == "hello"
assert response.http_response.status_code == 200
assert response.http_response.headers["x-ms-request-id"] == "body-request"


@pytest.mark.asyncio
async def test_get_no_content(client: BodyOrNoContentClient):
body, response = await client.get_no_content(cls=lambda x, y, z: (y, x))

assert body is None
assert response.http_response.status_code == 204
assert response.http_response.headers["x-ms-request-id"] == "no-content-request"
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -------------------------------------------------------------------------
# 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


@pytest.fixture
def client():
with BodyOrNoContentClient(endpoint="http://localhost:3000") as client:
yield client


def test_get_body(client: BodyOrNoContentClient):
body, response = client.get_body(cls=lambda x, y, z: (y, x))

assert body.content == "hello"
assert response.http_response.status_code == 200
assert response.http_response.headers["x-ms-request-id"] == "body-request"


def test_get_no_content(client: BodyOrNoContentClient):
body, response = client.get_no_content(cls=lambda x, y, z: (y, x))

assert body is None
assert response.http_response.status_code == 204
assert response.http_response.headers["x-ms-request-id"] == "no-content-request"
Loading