-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f6224e
commit 3f912d4
Showing
6 changed files
with
566 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
changeKind: internal | ||
packages: | ||
- "@azure-tools/typespec-python" | ||
--- | ||
|
||
add testcases for latest spector scenarios |
92 changes: 92 additions & 0 deletions
92
...ec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# ------------------------------------------------------------------------- | ||
# 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.resourcemanager.operationtemplates.aio import OperationTemplatesClient | ||
from azure.resourcemanager.operationtemplates import models | ||
|
||
SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000" | ||
RESOURCE_GROUP_NAME = "test-rg" | ||
|
||
|
||
@pytest.fixture | ||
async def client(credential, authentication_policy): | ||
async with OperationTemplatesClient( | ||
credential, | ||
SUBSCRIPTION_ID, | ||
"http://localhost:3000", | ||
authentication_policy=authentication_policy, | ||
) as client: | ||
yield client | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_check_name_availability_check_global(client): | ||
result = await client.check_name_availability.check_global( | ||
body=models.CheckNameAvailabilityRequest(name="checkName", type="Microsoft.Web/site") | ||
) | ||
assert result.name_available == False | ||
assert result.reason == models.CheckNameAvailabilityReason.ALREADY_EXISTS | ||
assert result.message == "Hostname 'checkName' already exists. Please select a different name." | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_check_name_availability_check_local(client): | ||
result = await client.check_name_availability.check_local( | ||
location="westus", | ||
body=models.CheckNameAvailabilityRequest(name="checkName", type="Microsoft.Web/site"), | ||
) | ||
assert result.name_available == False | ||
assert result.reason == models.CheckNameAvailabilityReason.ALREADY_EXISTS | ||
assert result.message == "Hostname 'checkName' already exists. Please select a different name." | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_operations_list(client): | ||
result = client.operations.list() | ||
assert result | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_lro_begin_create_or_replace(client): | ||
result = await ( | ||
await client.lro.begin_create_or_replace( | ||
resource_group_name=RESOURCE_GROUP_NAME, | ||
order_name="order1", | ||
resource=models.Order( | ||
location="eastus", | ||
properties=models.OrderProperties(product_id="product1", amount=1), | ||
), | ||
) | ||
).result() | ||
assert result.name == "order1" | ||
assert ( | ||
result.id | ||
== "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1" | ||
) | ||
assert result.type == "Azure.ResourceManager.Resources/orders" | ||
assert result.location == "eastus" | ||
assert result.system_data.created_by == "AzureSDK" | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_lro_begin_export(client): | ||
await ( | ||
await client.lro.begin_export( | ||
resource_group_name=RESOURCE_GROUP_NAME, | ||
order_name="order1", | ||
body=models.ExportRequest(format="csv"), | ||
) | ||
).result() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_lro_begin_delete(client): | ||
await ( | ||
await client.lro.begin_delete( | ||
resource_group_name=RESOURCE_GROUP_NAME, | ||
order_name="order1", | ||
) | ||
).result() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.