diff --git a/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md b/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md new file mode 100644 index 00000000000..14c091683a4 --- /dev/null +++ b/.chronus/changes/add-python-multiple-services-tests-2026-6-10-8-56-11.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock_api tests for the `service/multiple-services` Spector scenario and enable its regeneration. diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 1fe6f17d63c..61fda712aeb 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -72,7 +72,6 @@ export interface BuildTaskGroupsOptions { export const SKIP_SPECS: string[] = [ "type/file", - "service/multiple-services", "azure/client-generator-core/response-as-bool", ]; diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_service_multiple_services_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_service_multiple_services_async.py new file mode 100644 index 00000000000..df3a090325c --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_service_multiple_services_async.py @@ -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 service.multipleservices.servicea.aio import ServiceAClient +from service.multipleservices.serviceb.aio import ServiceBClient + + +@pytest_asyncio.fixture +async def client_a(): + async with ServiceAClient() as client: + yield client + + +@pytest_asyncio.fixture +async def client_b(): + async with ServiceBClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_service_a_op(client_a: ServiceAClient): + await client_a.operations.op_a() + + +@pytest.mark.asyncio +async def test_service_a_sub_namespace_op(client_a: ServiceAClient): + await client_a.sub_namespace.sub_op_a() + + +@pytest.mark.asyncio +async def test_service_b_op(client_b: ServiceBClient): + await client_b.operations.op_b() + + +@pytest.mark.asyncio +async def test_service_b_sub_namespace_op(client_b: ServiceBClient): + await client_b.sub_namespace.sub_op_b() diff --git a/packages/http-client-python/tests/mock_api/azure/test_service_multiple_services.py b/packages/http-client-python/tests/mock_api/azure/test_service_multiple_services.py new file mode 100644 index 00000000000..1949fba529c --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_service_multiple_services.py @@ -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 service.multipleservices.servicea import ServiceAClient +from service.multipleservices.serviceb import ServiceBClient + + +@pytest.fixture +def client_a(): + with ServiceAClient() as client: + yield client + + +@pytest.fixture +def client_b(): + with ServiceBClient() as client: + yield client + + +def test_service_a_op(client_a: ServiceAClient): + client_a.operations.op_a() + + +def test_service_a_sub_namespace_op(client_a: ServiceAClient): + client_a.sub_namespace.sub_op_a() + + +def test_service_b_op(client_b: ServiceBClient): + client_b.operations.op_b() + + +def test_service_b_sub_namespace_op(client_b: ServiceBClient): + client_b.sub_namespace.sub_op_b()