diff --git a/.chronus/changes/add-testcases-08-20-2025-7-20-14-42-52.md b/.chronus/changes/add-testcases-08-20-2025-7-20-14-42-52.md new file mode 100644 index 00000000000..8b5b1d0ef53 --- /dev/null +++ b/.chronus/changes/add-testcases-08-20-2025-7-20-14-42-52.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@azure-tools/typespec-python" +--- + +Add testcases for several spector scenarios \ No newline at end of file diff --git a/packages/typespec-python/scripts/eng/regenerate.ts b/packages/typespec-python/scripts/eng/regenerate.ts index 6b143843b30..55ac752483a 100644 --- a/packages/typespec-python/scripts/eng/regenerate.ts +++ b/packages/typespec-python/scripts/eng/regenerate.ts @@ -97,7 +97,7 @@ const AZURE_EMITTER_OPTIONS: Record | Record ## Getting started @@ -6,14 +6,14 @@ ### Install the package ```bash -python -m pip install client-naming +python -m pip install client-naming-main ``` #### Prequisites - Python 3.9 or later is required to use this package. - You need an [Azure subscription][azure_sub] to use this package. -- An existing Client Naming instance. +- An existing Client Naming Main instance. ## Contributing diff --git a/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json b/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json index c036da9bbf4..4a001f09f59 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json @@ -1,34 +1,34 @@ { "CrossLanguagePackageId": "Client.Naming", "CrossLanguageDefinitionId": { - "client.naming.models.ClientModel": "Client.Naming.Model.ModelWithClientClientName", - "client.naming.models.ClientNameAndJsonEncodedNameModel": "Client.Naming.Property.ClientNameAndJsonEncodedNameModel", - "client.naming.models.ClientNameModel": "Client.Naming.Property.ClientNameModel", - "client.naming.models.LanguageClientNameModel": "Client.Naming.Property.LanguageClientNameModel", - "client.naming.models.PythonModel": "Client.Naming.Model.ModelWithLanguageClientName", - "client.naming.models.ClientExtensibleEnum": "Client.Naming.UnionEnum.ServerExtensibleEnum", - "client.naming.models.ExtensibleEnum": "Client.Naming.UnionEnum.ExtensibleEnum", - "client.naming.operations.ModelClientOperations.client": "Client.Naming.Model.client", - "client.naming.aio.operations.ModelClientOperations.client": "Client.Naming.Model.client", - "client.naming.operations.ModelClientOperations.language": "Client.Naming.Model.language", - "client.naming.aio.operations.ModelClientOperations.language": "Client.Naming.Model.language", - "client.naming.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName", - "client.naming.aio.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName", - "client.naming.operations.UnionEnumOperations.union_enum_member_name": "Client.Naming.UnionEnum.unionEnumMemberName", - "client.naming.aio.operations.UnionEnumOperations.union_enum_member_name": "Client.Naming.UnionEnum.unionEnumMemberName", - "client.naming.NamingClient.client_name": "Client.Naming.operation", - "client.naming.aio.NamingClient.client_name": "Client.Naming.operation", - "client.naming.NamingClient.parameter": "Client.Naming.parameter", - "client.naming.aio.NamingClient.parameter": "Client.Naming.parameter", - "client.naming.NamingClient.client": "Client.Naming.Property.client", - "client.naming.aio.NamingClient.client": "Client.Naming.Property.client", - "client.naming.NamingClient.language": "Client.Naming.Property.language", - "client.naming.aio.NamingClient.language": "Client.Naming.Property.language", - "client.naming.NamingClient.compatible_with_encoded_name": "Client.Naming.Property.compatibleWithEncodedName", - "client.naming.aio.NamingClient.compatible_with_encoded_name": "Client.Naming.Property.compatibleWithEncodedName", - "client.naming.NamingClient.request": "Client.Naming.Header.request", - "client.naming.aio.NamingClient.request": "Client.Naming.Header.request", - "client.naming.NamingClient.response": "Client.Naming.Header.response", - "client.naming.aio.NamingClient.response": "Client.Naming.Header.response" + "client.naming.main.models.ClientModel": "Client.Naming.Model.ModelWithClientClientName", + "client.naming.main.models.ClientNameAndJsonEncodedNameModel": "Client.Naming.Property.ClientNameAndJsonEncodedNameModel", + "client.naming.main.models.ClientNameModel": "Client.Naming.Property.ClientNameModel", + "client.naming.main.models.LanguageClientNameModel": "Client.Naming.Property.LanguageClientNameModel", + "client.naming.main.models.PythonModel": "Client.Naming.Model.ModelWithLanguageClientName", + "client.naming.main.models.ClientExtensibleEnum": "Client.Naming.UnionEnum.ServerExtensibleEnum", + "client.naming.main.models.ExtensibleEnum": "Client.Naming.UnionEnum.ExtensibleEnum", + "client.naming.main.operations.ModelClientOperations.client": "Client.Naming.Model.client", + "client.naming.main.aio.operations.ModelClientOperations.client": "Client.Naming.Model.client", + "client.naming.main.operations.ModelClientOperations.language": "Client.Naming.Model.language", + "client.naming.main.aio.operations.ModelClientOperations.language": "Client.Naming.Model.language", + "client.naming.main.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName", + "client.naming.main.aio.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName", + "client.naming.main.operations.UnionEnumOperations.union_enum_member_name": "Client.Naming.UnionEnum.unionEnumMemberName", + "client.naming.main.aio.operations.UnionEnumOperations.union_enum_member_name": "Client.Naming.UnionEnum.unionEnumMemberName", + "client.naming.main.NamingClient.client_name": "Client.Naming.operation", + "client.naming.main.aio.NamingClient.client_name": "Client.Naming.operation", + "client.naming.main.NamingClient.parameter": "Client.Naming.parameter", + "client.naming.main.aio.NamingClient.parameter": "Client.Naming.parameter", + "client.naming.main.NamingClient.client": "Client.Naming.Property.client", + "client.naming.main.aio.NamingClient.client": "Client.Naming.Property.client", + "client.naming.main.NamingClient.language": "Client.Naming.Property.language", + "client.naming.main.aio.NamingClient.language": "Client.Naming.Property.language", + "client.naming.main.NamingClient.compatible_with_encoded_name": "Client.Naming.Property.compatibleWithEncodedName", + "client.naming.main.aio.NamingClient.compatible_with_encoded_name": "Client.Naming.Property.compatibleWithEncodedName", + "client.naming.main.NamingClient.request": "Client.Naming.Header.request", + "client.naming.main.aio.NamingClient.request": "Client.Naming.Header.request", + "client.naming.main.NamingClient.response": "Client.Naming.Header.response", + "client.naming.main.aio.NamingClient.response": "Client.Naming.Header.response" } } \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/__init__.py index dd86870d8cd..d55ccad1f57 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/__init__.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/__init__.py @@ -1,32 +1 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import NamingClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "NamingClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/__init__.py new file mode 100644 index 00000000000..dd86870d8cd --- /dev/null +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/__init__.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import NamingClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "NamingClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_client.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_client.py similarity index 96% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_client.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_client.py index f654b9adbb6..3846034d81d 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_client.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_client.py @@ -23,9 +23,9 @@ class NamingClient(_NamingClientOperationsMixin): # pylint: disable=client-acce """Describe changing names of types in a client with ``@clientName``. :ivar model_client: ModelClientOperations operations - :vartype model_client: client.naming.operations.ModelClientOperations + :vartype model_client: client.naming.main.operations.ModelClientOperations :ivar union_enum: UnionEnumOperations operations - :vartype union_enum: client.naming.operations.UnionEnumOperations + :vartype union_enum: client.naming.main.operations.UnionEnumOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_configuration.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_configuration.py similarity index 96% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_configuration.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_configuration.py index 35eaafa5fb7..f085617402f 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_configuration.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_configuration.py @@ -26,7 +26,7 @@ class NamingClientConfiguration: # pylint: disable=too-many-instance-attributes def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: self.endpoint = endpoint - kwargs.setdefault("sdk_moniker", "client-naming/{}".format(VERSION)) + kwargs.setdefault("sdk_moniker", "client-naming-main/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_patch.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_patch.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_patch.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_patch.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/__init__.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/__init__.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/__init__.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/model_base.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/model_base.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/model_base.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/model_base.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/serialization.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/serialization.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/serialization.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/serialization.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/utils.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/utils.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_utils/utils.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_utils/utils.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_version.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_version.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/_version.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/_version.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/__init__.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/__init__.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/__init__.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_client.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_client.py similarity index 96% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_client.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_client.py index a7499bbf986..ff0b2ee0dc1 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_client.py @@ -23,9 +23,9 @@ class NamingClient(_NamingClientOperationsMixin): # pylint: disable=client-acce """Describe changing names of types in a client with ``@clientName``. :ivar model_client: ModelClientOperations operations - :vartype model_client: client.naming.aio.operations.ModelClientOperations + :vartype model_client: client.naming.main.aio.operations.ModelClientOperations :ivar union_enum: UnionEnumOperations operations - :vartype union_enum: client.naming.aio.operations.UnionEnumOperations + :vartype union_enum: client.naming.main.aio.operations.UnionEnumOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_configuration.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_configuration.py similarity index 96% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_configuration.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_configuration.py index 1688b25d189..80c5652b2da 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_configuration.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_configuration.py @@ -26,7 +26,7 @@ class NamingClientConfiguration: # pylint: disable=too-many-instance-attributes def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: self.endpoint = endpoint - kwargs.setdefault("sdk_moniker", "client-naming/{}".format(VERSION)) + kwargs.setdefault("sdk_moniker", "client-naming-main/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_patch.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_patch.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_patch.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/_patch.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/operations/__init__.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/__init__.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/operations/__init__.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/operations/_operations.py similarity index 96% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/operations/_operations.py index 012320e68bd..a8569a9478a 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/operations/_operations.py @@ -55,7 +55,7 @@ class ModelClientOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~client.naming.aio.NamingClient`'s + :class:`~client.naming.main.aio.NamingClient`'s :attr:`model_client` attribute. """ @@ -71,7 +71,7 @@ async def client(self, body: _models.ClientModel, *, content_type: str = "applic """client. :param body: Required. - :type body: ~client.naming.models.ClientModel + :type body: ~client.naming.main.models.ClientModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -113,7 +113,7 @@ async def client(self, body: Union[_models.ClientModel, JSON, IO[bytes]], **kwar """client. :param body: Is one of the following types: ClientModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.ClientModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.ClientModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -171,7 +171,7 @@ async def language( """language. :param body: Required. - :type body: ~client.naming.models.PythonModel + :type body: ~client.naming.main.models.PythonModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -213,7 +213,7 @@ async def language(self, body: Union[_models.PythonModel, JSON, IO[bytes]], **kw """language. :param body: Is one of the following types: PythonModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.PythonModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.PythonModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +271,7 @@ class UnionEnumOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~client.naming.aio.NamingClient`'s + :class:`~client.naming.main.aio.NamingClient`'s :attr:`union_enum` attribute. """ @@ -287,7 +287,7 @@ async def union_enum_name(self, body: Union[str, _models.ClientExtensibleEnum], """union_enum_name. :param body: "value1" Required. - :type body: str or ~client.naming.models.ClientExtensibleEnum + :type body: str or ~client.naming.main.models.ClientExtensibleEnum :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -338,7 +338,7 @@ async def union_enum_member_name(self, body: Union[str, _models.ExtensibleEnum], """union_enum_member_name. :param body: Known values are: "value1" and "value2". Required. - :type body: str or ~client.naming.models.ExtensibleEnum + :type body: str or ~client.naming.main.models.ExtensibleEnum :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -487,7 +487,7 @@ async def client( """client. :param body: Required. - :type body: ~client.naming.models.ClientNameModel + :type body: ~client.naming.main.models.ClientNameModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -529,7 +529,7 @@ async def client(self, body: Union[_models.ClientNameModel, JSON, IO[bytes]], ** """client. :param body: Is one of the following types: ClientNameModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.ClientNameModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.ClientNameModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -587,7 +587,7 @@ async def language( """language. :param body: Required. - :type body: ~client.naming.models.LanguageClientNameModel + :type body: ~client.naming.main.models.LanguageClientNameModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -629,7 +629,7 @@ async def language(self, body: Union[_models.LanguageClientNameModel, JSON, IO[b """language. :param body: Is one of the following types: LanguageClientNameModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.LanguageClientNameModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.LanguageClientNameModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -687,7 +687,7 @@ async def compatible_with_encoded_name( """compatible_with_encoded_name. :param body: Required. - :type body: ~client.naming.models.ClientNameAndJsonEncodedNameModel + :type body: ~client.naming.main.models.ClientNameAndJsonEncodedNameModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -736,7 +736,7 @@ async def compatible_with_encoded_name( :param body: Is one of the following types: ClientNameAndJsonEncodedNameModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.ClientNameAndJsonEncodedNameModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.ClientNameAndJsonEncodedNameModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_patch.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/operations/_patch.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_patch.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/aio/operations/_patch.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/__init__.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/models/__init__.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/__init__.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_enums.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/_enums.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_enums.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/_enums.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_models.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/_models.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_models.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/_models.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_patch.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/_patch.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_patch.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/models/_patch.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/operations/__init__.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/__init__.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/operations/__init__.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/operations/_operations.py similarity index 97% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/operations/_operations.py index 8c0330b613f..33e65bb661a 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/operations/_operations.py @@ -179,7 +179,7 @@ class ModelClientOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~client.naming.NamingClient`'s + :class:`~client.naming.main.NamingClient`'s :attr:`model_client` attribute. """ @@ -195,7 +195,7 @@ def client(self, body: _models.ClientModel, *, content_type: str = "application/ """client. :param body: Required. - :type body: ~client.naming.models.ClientModel + :type body: ~client.naming.main.models.ClientModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -239,7 +239,7 @@ def client( # pylint: disable=inconsistent-return-statements """client. :param body: Is one of the following types: ClientModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.ClientModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.ClientModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -295,7 +295,7 @@ def language(self, body: _models.PythonModel, *, content_type: str = "applicatio """language. :param body: Required. - :type body: ~client.naming.models.PythonModel + :type body: ~client.naming.main.models.PythonModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -339,7 +339,7 @@ def language( # pylint: disable=inconsistent-return-statements """language. :param body: Is one of the following types: PythonModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.PythonModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.PythonModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +397,7 @@ class UnionEnumOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~client.naming.NamingClient`'s + :class:`~client.naming.main.NamingClient`'s :attr:`union_enum` attribute. """ @@ -415,7 +415,7 @@ def union_enum_name( # pylint: disable=inconsistent-return-statements """union_enum_name. :param body: "value1" Required. - :type body: str or ~client.naming.models.ClientExtensibleEnum + :type body: str or ~client.naming.main.models.ClientExtensibleEnum :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +468,7 @@ def union_enum_member_name( # pylint: disable=inconsistent-return-statements """union_enum_member_name. :param body: Known values are: "value1" and "value2". Required. - :type body: str or ~client.naming.models.ExtensibleEnum + :type body: str or ~client.naming.main.models.ExtensibleEnum :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -615,7 +615,7 @@ def client(self, body: _models.ClientNameModel, *, content_type: str = "applicat """client. :param body: Required. - :type body: ~client.naming.models.ClientNameModel + :type body: ~client.naming.main.models.ClientNameModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -659,7 +659,7 @@ def client( # pylint: disable=inconsistent-return-statements """client. :param body: Is one of the following types: ClientNameModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.ClientNameModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.ClientNameModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -717,7 +717,7 @@ def language( """language. :param body: Required. - :type body: ~client.naming.models.LanguageClientNameModel + :type body: ~client.naming.main.models.LanguageClientNameModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -761,7 +761,7 @@ def language( # pylint: disable=inconsistent-return-statements """language. :param body: Is one of the following types: LanguageClientNameModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.LanguageClientNameModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.LanguageClientNameModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -819,7 +819,7 @@ def compatible_with_encoded_name( """compatible_with_encoded_name. :param body: Required. - :type body: ~client.naming.models.ClientNameAndJsonEncodedNameModel + :type body: ~client.naming.main.models.ClientNameAndJsonEncodedNameModel :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -868,7 +868,7 @@ def compatible_with_encoded_name( # pylint: disable=inconsistent-return-stateme :param body: Is one of the following types: ClientNameAndJsonEncodedNameModel, JSON, IO[bytes] Required. - :type body: ~client.naming.models.ClientNameAndJsonEncodedNameModel or JSON or IO[bytes] + :type body: ~client.naming.main.models.ClientNameAndJsonEncodedNameModel or JSON or IO[bytes] :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_patch.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/operations/_patch.py similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_patch.py rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/operations/_patch.py diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/py.typed b/packages/typespec-python/test/azure/generated/client-naming/client/naming/main/py.typed similarity index 100% rename from packages/typespec-python/test/azure/generated/client-naming/client/naming/py.typed rename to packages/typespec-python/test/azure/generated/client-naming/client/naming/main/py.typed diff --git a/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer.py index 0b6e8178c61..eb60aedd870 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer.py +++ b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from client.naming import NamingClient +from client.naming.main import NamingClient from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer import functools diff --git a/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer_async.py index f306afdbed6..51d3a09395a 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer_async.py +++ b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/testpreparer_async.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from client.naming.aio import NamingClient +from client.naming.main.aio import NamingClient from devtools_testutils import AzureRecordedTestCase diff --git a/packages/typespec-python/test/azure/generated/client-naming/pyproject.toml b/packages/typespec-python/test/azure/generated/client-naming/pyproject.toml index 1d4729e03e9..759612dfc5d 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/pyproject.toml +++ b/packages/typespec-python/test/azure/generated/client-naming/pyproject.toml @@ -10,11 +10,11 @@ requires = ["setuptools>=77.0.3", "wheel"] build-backend = "setuptools.build_meta" [project] -name = "client-naming" +name = "client-naming-main" authors = [ { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, ] -description = "Microsoft Corporation Azure Client Naming Client Library for Python" +description = "Microsoft Corporation Azure Client Naming Main Client Library for Python" license = "MIT" classifiers = [ "Development Status :: 4 - Beta", @@ -43,7 +43,7 @@ dynamic = [ repository = "https://github.com/Azure/azure-sdk-for-python" [tool.setuptools.dynamic] -version = {attr = "client.naming._version.VERSION"} +version = {attr = "client.naming.main._version.VERSION"} readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} [tool.setuptools.packages.find] @@ -52,6 +52,7 @@ exclude = [ "samples*", "doc*", "client", + "client.naming", ] [tool.setuptools.package-data] diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py index fcbb859330e..39a26924925 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py @@ -4,8 +4,8 @@ # license information. # -------------------------------------------------------------------------- import pytest -from client.naming.aio import NamingClient -from client.naming import models +from client.naming.main.aio import NamingClient +from client.naming.main import models @pytest.fixture diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_enum_conflict_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_enum_conflict_async.py new file mode 100644 index 00000000000..27b7731d985 --- /dev/null +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_enum_conflict_async.py @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------- +# 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 client.naming.enumconflict.aio import EnumConflictClient +from client.naming.enumconflict.firstnamespace import models as first_models +from client.naming.enumconflict.secondnamespace import models as second_models + + +@pytest.fixture +async def client(): + async with EnumConflictClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_first_operations_first_async(client: EnumConflictClient): + """Test enum with same name in different namespace - first namespace (async).""" + body = first_models.FirstModel(status=first_models.Status.ACTIVE, name="test") + + response = await client.first_operations.first(body=body) + + assert response.status == "active" + assert response.name == "test" + + +@pytest.mark.asyncio +async def test_second_operations_second_async(client: EnumConflictClient): + """Test enum with same name in different namespace - second namespace (async).""" + body = second_models.SecondModel(status=second_models.SecondStatus.RUNNING, description="test description") + + response = await client.second_operations.second(body=body) + + assert response.status == "running" + assert response.description == "test description" diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py b/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py index 0ffdb4726e3..b0d12844958 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import pytest -from client.naming import NamingClient, models +from client.naming.main import NamingClient, models @pytest.fixture diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_client_naming_enum_conflict.py b/packages/typespec-python/test/azure/mock_api_tests/test_client_naming_enum_conflict.py new file mode 100644 index 00000000000..f32415a3615 --- /dev/null +++ b/packages/typespec-python/test/azure/mock_api_tests/test_client_naming_enum_conflict.py @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------- +# 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 client.naming.enumconflict import EnumConflictClient +from client.naming.enumconflict.firstnamespace import models as first_models +from client.naming.enumconflict.secondnamespace import models as second_models + + +@pytest.fixture +def client(): + with EnumConflictClient() as client: + yield client + + +def test_first_operations_first(client: EnumConflictClient): + """Test enum with same name in different namespace - first namespace.""" + body = first_models.FirstModel(status=first_models.Status.ACTIVE, name="test") + + response = client.first_operations.first(body=body) + + assert response.status == "active" + assert response.name == "test" + + +def test_second_operations_second(client: EnumConflictClient): + """Test enum with same name in different namespace - second namespace.""" + body = second_models.SecondModel(status=second_models.SecondStatus.RUNNING, description="test description") + + response = client.second_operations.second(body=body) + + assert response.status == "running" + assert response.description == "test description" diff --git a/packages/typespec-python/test/azure/requirements.txt b/packages/typespec-python/test/azure/requirements.txt index 2a80d520ffb..9329b242e79 100644 --- a/packages/typespec-python/test/azure/requirements.txt +++ b/packages/typespec-python/test/azure/requirements.txt @@ -32,6 +32,7 @@ azure-mgmt-core==1.6.0 -e ./generated/azure-payload-pageable -e ./generated/client-namespace -e ./generated/client-naming +-e ./generated/client-naming-enum-conflict -e ./generated/client-overload -e ./generated/client-structure-default -e ./generated/client-structure-multiclient