diff --git a/.chronus/changes/python-arm-service-group-tests-2026-7-27-8-59-27.md b/.chronus/changes/python-arm-service-group-tests-2026-7-27-8-59-27.md new file mode 100644 index 00000000000..330b02ebc10 --- /dev/null +++ b/.chronus/changes/python-arm-service-group-tests-2026-7-27-8-59-27.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add test coverage for Azure ARM service group extension resources and ARM resource identifier group scope diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_servicegroup_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_servicegroup_async.py new file mode 100644 index 00000000000..f10230c1e7e --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_arm_servicegroup_async.py @@ -0,0 +1,82 @@ +# ------------------------------------------------------------------------- +# 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.resourcemanager.servicegroupextension.aio import ServiceGroupExtensionClient +from azure.resourcemanager.servicegroupextension import models + +SERVICE_GROUP_ID = "test-sg" +RESOURCE_NAME = "resource" + + +@pytest_asyncio.fixture +async def client(credential, authentication_policy): + async with ServiceGroupExtensionClient( + credential, "http://localhost:3000", authentication_policy=authentication_policy + ) as client: + yield client + + +@pytest.mark.asyncio +async def test_service_group_extension_resources_get(client): + result = await client.service_group_extension_resources.get( + service_group_id=SERVICE_GROUP_ID, service_group_extension_resource_name=RESOURCE_NAME + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +@pytest.mark.asyncio +async def test_service_group_extension_resources_create_or_update(client): + result = await ( + await client.service_group_extension_resources.begin_create_or_update( + service_group_id=SERVICE_GROUP_ID, + service_group_extension_resource_name=RESOURCE_NAME, + resource=models.ServiceGroupExtensionResource( + properties=models.ServiceGroupExtensionResourceProperties(description="valid") + ), + polling_interval=0, + ) + ).result() + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +@pytest.mark.asyncio +async def test_service_group_extension_resources_update(client): + result = await client.service_group_extension_resources.update( + service_group_id=SERVICE_GROUP_ID, + service_group_extension_resource_name=RESOURCE_NAME, + properties=models.ServiceGroupExtensionResource( + properties=models.ServiceGroupExtensionResourceProperties(description="valid2") + ), + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid2" + assert result.properties.provisioning_state == "Succeeded" + + +@pytest.mark.asyncio +async def test_service_group_extension_resources_delete(client): + await client.service_group_extension_resources.delete( + service_group_id=SERVICE_GROUP_ID, service_group_extension_resource_name=RESOURCE_NAME + ) + + +@pytest.mark.asyncio +async def test_service_group_extension_resources_list_by_service_group(client): + result = [ + item + async for item in client.service_group_extension_resources.list_by_service_group( + service_group_id=SERVICE_GROUP_ID + ) + ] + assert len(result) == 1 + assert result[0].name == RESOURCE_NAME + assert result[0].properties.description == "valid" + assert result[0].properties.provisioning_state == "Succeeded" diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_arm_servicegroup.py b/packages/http-client-python/tests/mock_api/azure/test_azure_arm_servicegroup.py new file mode 100644 index 00000000000..d2c8b8c29db --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_arm_servicegroup.py @@ -0,0 +1,69 @@ +# ------------------------------------------------------------------------- +# 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.servicegroupextension import ServiceGroupExtensionClient +from azure.resourcemanager.servicegroupextension import models + +SERVICE_GROUP_ID = "test-sg" +RESOURCE_NAME = "resource" + + +@pytest.fixture +def client(credential, authentication_policy): + with ServiceGroupExtensionClient( + credential, "http://localhost:3000", authentication_policy=authentication_policy + ) as client: + yield client + + +def test_service_group_extension_resources_get(client): + result = client.service_group_extension_resources.get( + service_group_id=SERVICE_GROUP_ID, service_group_extension_resource_name=RESOURCE_NAME + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +def test_service_group_extension_resources_create_or_update(client): + result = client.service_group_extension_resources.begin_create_or_update( + service_group_id=SERVICE_GROUP_ID, + service_group_extension_resource_name=RESOURCE_NAME, + resource=models.ServiceGroupExtensionResource( + properties=models.ServiceGroupExtensionResourceProperties(description="valid") + ), + polling_interval=0, + ).result() + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid" + assert result.properties.provisioning_state == "Succeeded" + + +def test_service_group_extension_resources_update(client): + result = client.service_group_extension_resources.update( + service_group_id=SERVICE_GROUP_ID, + service_group_extension_resource_name=RESOURCE_NAME, + properties=models.ServiceGroupExtensionResource( + properties=models.ServiceGroupExtensionResourceProperties(description="valid2") + ), + ) + assert result.name == RESOURCE_NAME + assert result.properties.description == "valid2" + assert result.properties.provisioning_state == "Succeeded" + + +def test_service_group_extension_resources_delete(client): + client.service_group_extension_resources.delete( + service_group_id=SERVICE_GROUP_ID, service_group_extension_resource_name=RESOURCE_NAME + ) + + +def test_service_group_extension_resources_list_by_service_group(client): + result = list(client.service_group_extension_resources.list_by_service_group(service_group_id=SERVICE_GROUP_ID)) + assert len(result) == 1 + assert result[0].name == RESOURCE_NAME + assert result[0].properties.description == "valid" + assert result[0].properties.provisioning_state == "Succeeded"