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 Python sync and async mock API tests for failed LRO result polling.
22 changes: 11 additions & 11 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.

4 changes: 2 additions & 2 deletions packages/http-client-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
"@azure-tools/typespec-azure-core": "~0.74.0",
"@azure-tools/typespec-azure-resource-manager": "~0.74.0",
"@azure-tools/typespec-azure-rulesets": "~0.74.0",
"@azure-tools/typespec-client-generator-core": "~0.74.0",
"@azure-tools/azure-http-specs": "0.1.0-alpha.47",
"@azure-tools/typespec-client-generator-core": "0.75.0-dev.5",
"@azure-tools/azure-http-specs": "0.1.0-alpha.48-dev.3",
"@typespec/compiler": "^1.18.0",
"@typespec/http": "^1.18.0",
"@typespec/openapi": "^1.18.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -------------------------------------------------------------------------
# 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.exceptions import HttpResponseError

from specs.azure.clientgenerator.core.lro.result.aio import ResultClient
from specs.azure.clientgenerator.core.lro.result.models import Job


@pytest_asyncio.fixture
async def client():
async with ResultClient() as client:
yield client


@pytest.mark.asyncio
async def test_default_lro_result_failure(client, async_polling_method):
poller = await client.begin_create_default_failure(
id="default-failure",
resource=Job(status="Running"),
polling_interval=0,
polling=async_polling_method,
)
with pytest.raises(HttpResponseError):
await poller.result()


@pytest.mark.asyncio
async def test_client_lro_result_failure(client, async_polling_method):
poller = await client.begin_create_client_result_failure(
id="client-result-failure",
resource=Job(status="Running"),
polling_interval=0,
polling=async_polling_method,
)
with pytest.raises(HttpResponseError):
await poller.result()
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
from azure.core.exceptions import HttpResponseError

from specs.azure.clientgenerator.core.lro.result import ResultClient
from specs.azure.clientgenerator.core.lro.result.models import Job


@pytest.fixture
def client():
with ResultClient() as client:
yield client


def test_default_lro_result_failure(client, polling_method):
with pytest.raises(HttpResponseError):
client.begin_create_default_failure(
id="default-failure",
resource=Job(status="Running"),
polling_interval=0,
polling=polling_method,
).result()


def test_client_lro_result_failure(client, polling_method):
with pytest.raises(HttpResponseError):
client.begin_create_client_result_failure(
id="client-result-failure",
resource=Job(status="Running"),
polling_interval=0,
polling=polling_method,
).result()