From 25bf66df6d702da4b8c6655d798d054aaf377134 Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Mon, 6 May 2024 15:19:15 -0400 Subject: [PATCH] get cadl ranch coverage to 100% with latest cadl-ranch (#2571) --- ...d_cadl_ranch_coverage-2024-4-6-12-43-56.md | 7 + packages/typespec-python/package.json | 2 +- .../apiview_mapping_python.json | 6 +- .../duration/aio/operations/_operations.py | 258 ++++++++++++++ .../encode/duration/models/__init__.py | 2 + .../encode/duration/models/_models.py | 30 ++ .../encode/duration/operations/_operations.py | 294 ++++++++++++++++ .../test_duration_header_operations.py | 11 + .../test_duration_header_operations_async.py | 11 + .../test_duration_property_operations.py | 11 + ...test_duration_property_operations_async.py | 11 + .../test_duration_query_operations.py | 11 + .../test_duration_query_operations_async.py | 11 + ...azure_client_generator_core_usage_async.py | 1 + .../asynctests/test_azure_core_basic_async.py | 10 +- .../test_azure_core_lro_rpc_async.py | 5 +- .../test_azure_core_lro_standard_async.py | 16 +- .../test_azure_core_scalar_async.py | 4 +- .../test_azure_core_traits_async.py | 9 +- ...special_headers_client_request_id_async.py | 5 +- .../test/azure/mock_api_tests/conftest.py | 31 +- .../test_azure_client_generator_core_usage.py | 2 + .../mock_api_tests/test_azure_core_basic.py | 6 + .../mock_api_tests/test_azure_core_lro_rpc.py | 5 +- .../test_azure_core_lro_standard.py | 10 +- .../mock_api_tests/test_azure_core_scalar.py | 4 +- .../mock_api_tests/test_azure_core_traits.py | 9 +- ...azure_special_headers_client_request_id.py | 5 +- .../mock_api_tests/test_mgmt_models_mode.py | 3 +- .../asynctests/test_encode_duration_async.py | 4 + .../test_parameters_spread_async.py | 16 +- .../test_payload_multipart_async.py | 5 + .../test_resiliency_srv_driven_async.py | 32 +- .../test_typetest_model_flatten_async.py | 13 +- ...el_inheritance_enum_discriminator_async.py | 8 +- ..._inheritance_nested_discriminator_async.py | 5 +- ...etest_model_inheritance_recursive_async.py | 7 +- ...est_property_additionalproperties_async.py | 85 ++++- .../test_typetest_property_nullable_async.py | 3 +- .../test_typetest_property_optional_async.py | 5 +- ...test_typetest_property_valuetypes_async.py | 53 +++ .../asynctests/test_versioning_added_async.py | 6 +- .../test_versioning_made_optional_async.py | 4 +- .../test_versioning_removed_async.py | 6 +- .../test_versioning_renamed_from_async.py | 4 +- ...rsioning_return_type_changed_from_async.py | 4 +- ...test_versioning_type_changed_from_async.py | 4 +- .../test_encode_duration.py | 4 + .../test_parameters_spread.py | 8 +- .../test_payload_multipart.py | 5 + .../test_resiliency_srv_driven.py | 32 +- .../test_typetest_model_flatten.py | 13 +- ..._model_inheritance_nested_discriminator.py | 5 +- ...st_typetest_model_inheritance_recursive.py | 7 +- ..._typetest_property_additionalproperties.py | 73 +++- .../test_typetest_property_nullable.py | 3 +- .../test_typetest_property_optional.py | 5 +- .../test_typetest_property_valuetypes.py | 54 +++ .../test_versioning_added.py | 6 +- .../test_versioning_removed.py | 6 +- ...est_versioning_return_type_changed_from.py | 5 +- .../test_versioning_type_changed_from.py | 4 +- .../test_model_base_serialization.py | 324 +++++++++++++++--- .../duration/aio/operations/_operations.py | 255 ++++++++++++++ .../encode/duration/models/__init__.py | 2 + .../encode/duration/models/_models.py | 30 ++ .../encode/duration/operations/_operations.py | 291 ++++++++++++++++ .../test/unbranded/mock_api_tests/conftest.py | 8 +- .../mock_api_tests/test_unbranded.py | 4 +- pnpm-lock.yaml | 8 +- 70 files changed, 1991 insertions(+), 215 deletions(-) create mode 100644 .chronus/changes/add_cadl_ranch_coverage-2024-4-6-12-43-56.md diff --git a/.chronus/changes/add_cadl_ranch_coverage-2024-4-6-12-43-56.md b/.chronus/changes/add_cadl_ranch_coverage-2024-4-6-12-43-56.md new file mode 100644 index 00000000000..52e1d0f8712 --- /dev/null +++ b/.chronus/changes/add_cadl_ranch_coverage-2024-4-6-12-43-56.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-python" +--- + +add tests for cadl-ranch and fix api version issue with multiple clients \ No newline at end of file diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 6eb058425bf..3b4f428eab3 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -66,7 +66,7 @@ "@azure-tools/typespec-azure-resource-manager": "~0.41.0", "@azure-tools/typespec-autorest": "~0.41.0", "@azure-tools/cadl-ranch-expect": "~0.13.3", - "@azure-tools/cadl-ranch-specs": "~0.33.1", + "@azure-tools/cadl-ranch-specs": "~0.33.2", "@types/js-yaml": "~4.0.5", "@types/mocha": "~10.0.1", "@types/node": "^18.16.3", diff --git a/packages/typespec-python/test/azure/generated/encode-duration/apiview_mapping_python.json b/packages/typespec-python/test/azure/generated/encode-duration/apiview_mapping_python.json index 541a645dab7..0d62c4e2e33 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/apiview_mapping_python.json +++ b/packages/typespec-python/test/azure/generated/encode-duration/apiview_mapping_python.json @@ -2,6 +2,7 @@ "CrossLanguagePackageId": "Encode.Duration", "CrossLanguageDefinitionId": { "encode.duration.models.DefaultDurationProperty": "Encode.Duration.Property.DefaultDurationProperty", + "encode.duration.models.Float64SecondsDurationProperty": "Encode.Duration.Property.Float64SecondsDurationProperty", "encode.duration.models.FloatSecondsDurationArrayProperty": "Encode.Duration.Property.FloatSecondsDurationArrayProperty", "encode.duration.models.FloatSecondsDurationProperty": "Encode.Duration.Property.FloatSecondsDurationProperty", "encode.duration.models.Int32SecondsDurationProperty": "Encode.Duration.Property.Int32SecondsDurationProperty", @@ -10,16 +11,19 @@ "encode.duration.DurationClient.query.iso8601": "Encode.Duration.Query.iso8601", "encode.duration.DurationClient.query.int32_seconds": "Encode.Duration.Query.int32Seconds", "encode.duration.DurationClient.query.float_seconds": "Encode.Duration.Query.floatSeconds", + "encode.duration.DurationClient.query.float64_seconds": "Encode.Duration.Query.float64Seconds", "encode.duration.DurationClient.query.int32_seconds_array": "Encode.Duration.Query.int32SecondsArray", "encode.duration.DurationClient.property.default": "Encode.Duration.Property.default", "encode.duration.DurationClient.property.iso8601": "Encode.Duration.Property.iso8601", "encode.duration.DurationClient.property.int32_seconds": "Encode.Duration.Property.int32Seconds", "encode.duration.DurationClient.property.float_seconds": "Encode.Duration.Property.floatSeconds", + "encode.duration.DurationClient.property.float64_seconds": "Encode.Duration.Property.float64Seconds", "encode.duration.DurationClient.property.float_seconds_array": "Encode.Duration.Property.floatSecondsArray", "encode.duration.DurationClient.header.default": "Encode.Duration.Header.default", "encode.duration.DurationClient.header.iso8601": "Encode.Duration.Header.iso8601", "encode.duration.DurationClient.header.iso8601_array": "Encode.Duration.Header.iso8601Array", "encode.duration.DurationClient.header.int32_seconds": "Encode.Duration.Header.int32Seconds", - "encode.duration.DurationClient.header.float_seconds": "Encode.Duration.Header.floatSeconds" + "encode.duration.DurationClient.header.float_seconds": "Encode.Duration.Header.floatSeconds", + "encode.duration.DurationClient.header.float64_seconds": "Encode.Duration.Header.float64Seconds" } } \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/aio/operations/_operations.py index cf3ca630582..6caf7a9a109 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/aio/operations/_operations.py @@ -29,16 +29,19 @@ from ..._model_base import SdkJSONEncoder, _deserialize from ...operations._operations import ( build_header_default_request, + build_header_float64_seconds_request, build_header_float_seconds_request, build_header_int32_seconds_request, build_header_iso8601_array_request, build_header_iso8601_request, build_property_default_request, + build_property_float64_seconds_request, build_property_float_seconds_array_request, build_property_float_seconds_request, build_property_int32_seconds_request, build_property_iso8601_request, build_query_default_request, + build_query_float64_seconds_request, build_query_float_seconds_request, build_query_int32_seconds_array_request, build_query_int32_seconds_request, @@ -263,6 +266,54 @@ async def float_seconds( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace_async + async def float64_seconds( # pylint: disable=inconsistent-return-statements + self, *, input: float, **kwargs: Any + ) -> None: + """float64_seconds. + + :keyword input: Required. + :paramtype input: float + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_query_float64_seconds_request( + input=input, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace_async async def int32_seconds_array( # pylint: disable=inconsistent-return-statements self, *, input: List[int], **kwargs: Any @@ -955,6 +1006,165 @@ async def float_seconds( return deserialized # type: ignore + @overload + async def float64_seconds( + self, body: _models.Float64SecondsDurationProperty, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + async def float64_seconds( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + async def float64_seconds( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @distributed_trace_async + async def float64_seconds( + self, body: Union[_models.Float64SecondsDurationProperty, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Is one of the following types: Float64SecondsDurationProperty, JSON, IO[bytes] + Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty or JSON or IO[bytes] + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Float64SecondsDurationProperty] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_property_float64_seconds_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Float64SecondsDurationProperty, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload async def float_seconds_array( self, body: _models.FloatSecondsDurationArrayProperty, *, content_type: str = "application/json", **kwargs: Any @@ -1383,3 +1593,51 @@ async def float_seconds( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def float64_seconds( # pylint: disable=inconsistent-return-statements + self, *, duration: float, **kwargs: Any + ) -> None: + """float64_seconds. + + :keyword duration: Required. + :paramtype duration: float + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_header_float64_seconds_request( + duration=duration, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/__init__.py b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/__init__.py index 6400f56b3e0..df5f04a3e4f 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/__init__.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/__init__.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from ._models import DefaultDurationProperty +from ._models import Float64SecondsDurationProperty from ._models import FloatSecondsDurationArrayProperty from ._models import FloatSecondsDurationProperty from ._models import ISO8601DurationProperty @@ -17,6 +18,7 @@ __all__ = [ "DefaultDurationProperty", + "Float64SecondsDurationProperty", "FloatSecondsDurationArrayProperty", "FloatSecondsDurationProperty", "ISO8601DurationProperty", diff --git a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py index 98dea8aab3e..c56a43c7b31 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py @@ -44,6 +44,36 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles super().__init__(*args, **kwargs) +class Float64SecondsDurationProperty(_model_base.Model): + """Float64SecondsDurationProperty. + + All required parameters must be populated in order to send to server. + + :ivar value: Required. + :vartype value: float + """ + + value: float = rest_field() + """Required.""" + + @overload + def __init__( + self, + *, + value: float, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + class FloatSecondsDurationArrayProperty(_model_base.Model): """FloatSecondsDurationArrayProperty. diff --git a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/operations/_operations.py b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/operations/_operations.py index 9f7e11e0584..f9370826d0e 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/operations/_operations.py @@ -89,6 +89,18 @@ def build_query_float_seconds_request(*, input: float, **kwargs: Any) -> HttpReq return HttpRequest(method="GET", url=_url, params=_params, **kwargs) +def build_query_float64_seconds_request(*, input: float, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + # Construct URL + _url = "/encode/duration/query/float64-seconds" + + # Construct parameters + _params["input"] = _SERIALIZER.query("input", input, "float") + + return HttpRequest(method="GET", url=_url, params=_params, **kwargs) + + def build_query_int32_seconds_array_request(*, input: List[int], **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -169,6 +181,23 @@ def build_property_float_seconds_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) +def build_property_float64_seconds_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/encode/duration/property/float64-seconds" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + def build_property_float_seconds_array_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -246,6 +275,18 @@ def build_header_float_seconds_request(*, duration: float, **kwargs: Any) -> Htt return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) +def build_header_float64_seconds_request(*, duration: float, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + # Construct URL + _url = "/encode/duration/header/float64-seconds" + + # Construct headers + _headers["duration"] = _SERIALIZER.header("duration", duration, "float") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + class QueryOperations: """ .. warning:: @@ -451,6 +492,52 @@ def float_seconds(self, *, input: float, **kwargs: Any) -> None: # pylint: disa if cls: return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace + def float64_seconds(self, *, input: float, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """float64_seconds. + + :keyword input: Required. + :paramtype input: float + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_query_float64_seconds_request( + input=input, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace def int32_seconds_array( # pylint: disable=inconsistent-return-statements self, *, input: List[int], **kwargs: Any @@ -1143,6 +1230,165 @@ def float_seconds( return deserialized # type: ignore + @overload + def float64_seconds( + self, body: _models.Float64SecondsDurationProperty, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + def float64_seconds( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + def float64_seconds( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @distributed_trace + def float64_seconds( + self, body: Union[_models.Float64SecondsDurationProperty, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Is one of the following types: Float64SecondsDurationProperty, JSON, IO[bytes] + Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty or JSON or IO[bytes] + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Float64SecondsDurationProperty] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_property_float64_seconds_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Float64SecondsDurationProperty, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload def float_seconds_array( self, body: _models.FloatSecondsDurationArrayProperty, *, content_type: str = "application/json", **kwargs: Any @@ -1569,3 +1815,51 @@ def float_seconds( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def float64_seconds( # pylint: disable=inconsistent-return-statements + self, *, duration: float, **kwargs: Any + ) -> None: + """float64_seconds. + + :keyword duration: Required. + :paramtype duration: float + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_header_float64_seconds_request( + duration=duration, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations.py b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations.py index 4c8198bee5f..dcdc9e96f7f 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations.py @@ -66,3 +66,14 @@ def test_float_seconds(self, duration_endpoint): # please add some check logic here by yourself # ... + + @DurationPreparer() + @recorded_by_proxy + def test_float64_seconds(self, duration_endpoint): + client = self.create_client(endpoint=duration_endpoint) + response = client.header.float64_seconds( + duration=0.0, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations_async.py b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations_async.py index efe3f60e969..42a08e80f61 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations_async.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_header_operations_async.py @@ -67,3 +67,14 @@ async def test_float_seconds(self, duration_endpoint): # please add some check logic here by yourself # ... + + @DurationPreparer() + @recorded_by_proxy_async + async def test_float64_seconds(self, duration_endpoint): + client = self.create_async_client(endpoint=duration_endpoint) + response = await client.header.float64_seconds( + duration=0.0, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations.py b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations.py index bfbd0f08037..5295faefb08 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations.py @@ -56,6 +56,17 @@ def test_float_seconds(self, duration_endpoint): # please add some check logic here by yourself # ... + @DurationPreparer() + @recorded_by_proxy + def test_float64_seconds(self, duration_endpoint): + client = self.create_client(endpoint=duration_endpoint) + response = client.property.float64_seconds( + body={"value": 0.0}, + ) + + # please add some check logic here by yourself + # ... + @DurationPreparer() @recorded_by_proxy def test_float_seconds_array(self, duration_endpoint): diff --git a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations_async.py b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations_async.py index 5776ef1530c..bf73c7dc33e 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations_async.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_property_operations_async.py @@ -57,6 +57,17 @@ async def test_float_seconds(self, duration_endpoint): # please add some check logic here by yourself # ... + @DurationPreparer() + @recorded_by_proxy_async + async def test_float64_seconds(self, duration_endpoint): + client = self.create_async_client(endpoint=duration_endpoint) + response = await client.property.float64_seconds( + body={"value": 0.0}, + ) + + # please add some check logic here by yourself + # ... + @DurationPreparer() @recorded_by_proxy_async async def test_float_seconds_array(self, duration_endpoint): diff --git a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations.py b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations.py index 6d2a2334c67..56d3fe40113 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations.py @@ -56,6 +56,17 @@ def test_float_seconds(self, duration_endpoint): # please add some check logic here by yourself # ... + @DurationPreparer() + @recorded_by_proxy + def test_float64_seconds(self, duration_endpoint): + client = self.create_client(endpoint=duration_endpoint) + response = client.query.float64_seconds( + input=0.0, + ) + + # please add some check logic here by yourself + # ... + @DurationPreparer() @recorded_by_proxy def test_int32_seconds_array(self, duration_endpoint): diff --git a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations_async.py b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations_async.py index 47775238588..a5297e40508 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations_async.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/generated_tests/test_duration_query_operations_async.py @@ -57,6 +57,17 @@ async def test_float_seconds(self, duration_endpoint): # please add some check logic here by yourself # ... + @DurationPreparer() + @recorded_by_proxy_async + async def test_float64_seconds(self, duration_endpoint): + client = self.create_async_client(endpoint=duration_endpoint) + response = await client.query.float64_seconds( + input=0.0, + ) + + # please add some check logic here by yourself + # ... + @DurationPreparer() @recorded_by_proxy_async async def test_int32_seconds_array(self, duration_endpoint): diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_usage_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_usage_async.py index c4ebe49515b..ca8c6ebafa2 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_usage_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_usage_async.py @@ -18,6 +18,7 @@ async def client(): async def test_input_to_input_output(client: UsageClient): await client.model_in_operation.input_to_input_output(models.InputModel(name="Madge")) + @pytest.mark.asyncio async def test_output_to_input_output(client: UsageClient): assert models.OutputModel(name="Madge") == await client.model_in_operation.output_to_input_output() diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_basic_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_basic_async.py index 5791b61c404..dcde332559a 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_basic_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_basic_async.py @@ -9,6 +9,7 @@ VALID_USER = models.User(id=1, name="Madge", etag="11bdc430-65e8-45ad-81d9-8ffa60d55b59") + @pytest.fixture async def client(): async with aio.BasicClient() as client: @@ -58,6 +59,7 @@ async def test_list(client: aio.BasicClient): assert result[1].orders[0].user_id == 2 assert result[1].orders[0].detail == "a TV" + async def _list_with_page_tests(pager: AsyncIterable[models.User]): result = [p async for p in pager] assert len(result) == 1 @@ -66,10 +68,12 @@ async def _list_with_page_tests(pager: AsyncIterable[models.User]): assert result[0].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59" assert result[0].orders is None + @pytest.mark.asyncio async def test_list_with_page(client: aio.BasicClient): await _list_with_page_tests(client.list_with_page()) + @pytest.mark.asyncio async def test_list_with_custom_page_model(client: aio.BasicClient): await _list_with_page_tests(client.list_with_custom_page_model()) @@ -90,10 +94,14 @@ async def test_export(client: aio.BasicClient): @pytest.mark.asyncio async def test_list_with_parameters(client: aio.BasicClient): - result = [item async for item in client.list_with_parameters(models.ListItemInputBody(input_name="Madge"), another="Second")] + result = [ + item + async for item in client.list_with_parameters(models.ListItemInputBody(input_name="Madge"), another="Second") + ] assert len(result) == 1 assert result[0] == VALID_USER + @pytest.mark.asyncio async def test_two_models_as_page_item(client: aio.BasicClient): result = [item async for item in client.two_models_as_page_item.list_first_item()] diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_rpc_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_rpc_async.py index edbb84d4042..9845640649a 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_rpc_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_rpc_async.py @@ -13,7 +13,10 @@ async def client(): async with RpcClient() as client: yield client + @pytest.mark.asyncio async def test_long_running_rpc(client: RpcClient, async_polling_method): - result = await client.begin_long_running_rpc(models.GenerationOptions(prompt="text"), polling_interval=0, polling=async_polling_method) + result = await client.begin_long_running_rpc( + models.GenerationOptions(prompt="text"), polling_interval=0, polling=async_polling_method + ) assert (await result.result()) == models.GenerationResult(data="text data") diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_standard_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_standard_async.py index f4673a71a71..b9b00668cae 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_standard_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_lro_standard_async.py @@ -7,23 +7,33 @@ from specs.azure.core.lro.standard.aio import StandardClient from specs.azure.core.lro.standard.models import User, ExportedUser + @pytest.fixture async def client(): async with StandardClient() as client: yield client + @pytest.mark.asyncio async def test_lro_core_put(client, async_polling_method): user = User({"name": "madge", "role": "contributor"}) - result = await (await client.begin_create_or_replace(name=user.name, resource=user, polling_interval=0, polling=async_polling_method)).result() + result = await ( + await client.begin_create_or_replace( + name=user.name, resource=user, polling_interval=0, polling=async_polling_method + ) + ).result() assert result == user + @pytest.mark.asyncio async def test_lro_core_delete(client, async_polling_method): await (await client.begin_delete(name="madge", polling_interval=0, polling=async_polling_method)).result() + @pytest.mark.asyncio async def test_lro_core_export(client, async_polling_method): - export_user = ExportedUser({ "name": "madge", "resourceUri": "/users/madge" }) - result = await (await client.begin_export(name="madge", format="json", polling_interval=0, polling=async_polling_method)).result() + export_user = ExportedUser({"name": "madge", "resourceUri": "/users/madge"}) + result = await ( + await client.begin_export(name="madge", format="json", polling_interval=0, polling=async_polling_method) + ).result() assert result == export_user diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_scalar_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_scalar_async.py index ab6e195d41d..1fc7d171bad 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_scalar_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_scalar_async.py @@ -24,9 +24,7 @@ async def test_azure_location_scalar_put(client: ScalarClient): async def test_azure_location_scalar_post(client: ScalarClient): - result = await client.azure_location_scalar.post( - models.AzureLocationModel(location="eastus") - ) + result = await client.azure_location_scalar.post(models.AzureLocationModel(location="eastus")) assert result == models.AzureLocationModel(location="eastus") diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_traits_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_traits_async.py index 2fff9641100..dca81854423 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_traits_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_core_traits_async.py @@ -26,12 +26,8 @@ async def assert_test_get(**kwargs): result, header = await client.smoke_test( id=1, foo="123", - if_unmodified_since=datetime( - year=2022, month=8, day=26, hour=14, minute=38, second=0 - ), - if_modified_since=datetime( - year=2021, month=8, day=26, hour=14, minute=38, second=0 - ), + if_unmodified_since=datetime(year=2022, month=8, day=26, hour=14, minute=38, second=0), + if_modified_since=datetime(year=2021, month=8, day=26, hour=14, minute=38, second=0), cls=lambda x, y, z: (y, z), raw_request_hook=functools.partial( check_client_request_id_header, header="x-ms-client-request-id", checked=checked @@ -49,6 +45,7 @@ async def assert_test_get(**kwargs): with pytest.raises(HttpResponseError): await assert_test_get() + @pytest.mark.asyncio async def test_repeatable_action(client: TraitsClient, check_repeatability_header): result, header = await client.repeatable_action( diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_special_headers_client_request_id_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_special_headers_client_request_id_async.py index 02d12b75017..b89ee4b732c 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_special_headers_client_request_id_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_special_headers_client_request_id_async.py @@ -26,8 +26,5 @@ async def test_get(client: XmsClientRequestIdClient, check_client_request_id_hea ), ) assert result is None - assert ( - resp.http_response.headers["x-ms-client-request-id"] - == checked["x-ms-client-request-id"] - ) + assert resp.http_response.headers["x-ms-client-request-id"] == checked["x-ms-client-request-id"] pass diff --git a/packages/typespec-python/test/azure/mock_api_tests/conftest.py b/packages/typespec-python/test/azure/mock_api_tests/conftest.py index c7e25fe6902..c90503bcaba 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/conftest.py +++ b/packages/typespec-python/test/azure/mock_api_tests/conftest.py @@ -11,6 +11,7 @@ from typing import Literal from pathlib import Path + def start_server_process(): path = Path(os.path.dirname(__file__)) / Path("../../../node_modules/@azure-tools/cadl-ranch-specs") os.chdir(path.resolve()) @@ -19,12 +20,14 @@ def start_server_process(): return subprocess.Popen(cmd, shell=True) return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid) + def terminate_server_process(process): - if os.name == 'nt': + if os.name == "nt": process.kill() else: os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups + @pytest.fixture(scope="session", autouse=True) def testserver(): """Start cadl ranch mock api tests""" @@ -39,6 +42,7 @@ def testserver(): r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT$" ) + def validate_format(value: str, format: Literal["uuid", "rfc7231"]): if format == "uuid": assert _VALID_UUID.match(value) @@ -47,31 +51,31 @@ def validate_format(value: str, format: Literal["uuid", "rfc7231"]): else: raise ValueError("Unknown format") + @pytest.fixture def check_repeatability_header(): def func(request): - validate_format( - request.http_request.headers["Repeatability-Request-ID"], "uuid" - ) - validate_format( - request.http_request.headers["Repeatability-First-Sent"], "rfc7231" - ) + validate_format(request.http_request.headers["Repeatability-Request-ID"], "uuid") + validate_format(request.http_request.headers["Repeatability-First-Sent"], "rfc7231") + return func + @pytest.fixture def check_client_request_id_header(): def func(request, header: str, checked: dict): validate_format(request.http_request.headers[header], "uuid") checked[header] = request.http_request.headers[header] + return func + # ================== after azure-core fix, the following code can be removed (begin) ================== import urllib.parse from azure.core.rest import HttpRequest -def update_api_version_of_status_link( - status_link: str -): + +def update_api_version_of_status_link(status_link: str): request_params = {} parsed_status_link = urllib.parse.urlparse(status_link) request_params = { @@ -82,6 +86,7 @@ def update_api_version_of_status_link( status_link = urllib.parse.urljoin(status_link, parsed_status_link.path) return status_link, request_params + @pytest.fixture def polling_method(): from azure.core.polling.base_polling import LROBasePolling @@ -100,6 +105,7 @@ def request_status(self, status_link: str): return TempLroBasePolling(0) + @pytest.fixture def async_polling_method(): from azure.core.polling.async_base_polling import AsyncLROBasePolling @@ -115,8 +121,11 @@ async def request_status(self, status_link: str): self._operation_config["request_id"] = self._get_request_id() rest_request = HttpRequest("GET", status_link, params=request_params) - return await self._client.send_request(rest_request, _return_pipeline_response=True, **self._operation_config) + return await self._client.send_request( + rest_request, _return_pipeline_response=True, **self._operation_config + ) return AsyncTempLroBasePolling(0) + # ================== after azure-core fix, the up code can be removed (end) ================== diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_client_generator_core_usage.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_client_generator_core_usage.py index 9634d25a7fa..829f2ccd3e2 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_client_generator_core_usage.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_client_generator_core_usage.py @@ -17,8 +17,10 @@ def client(): def test_input_to_input_output(client: UsageClient): client.model_in_operation.input_to_input_output(models.InputModel(name="Madge")) + def test_output_to_input_output(client: UsageClient): assert models.OutputModel(name="Madge") == client.model_in_operation.output_to_input_output() + def test_model_usage(): from specs.azure.clientgenerator.core.usage.models import OrphanModel diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_basic.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_basic.py index 1c2ca490104..150a7e1259d 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_basic.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_basic.py @@ -9,6 +9,7 @@ VALID_USER = models.User(id=1, name="Madge", etag="11bdc430-65e8-45ad-81d9-8ffa60d55b59") + @pytest.fixture def client(): with BasicClient() as client: @@ -29,6 +30,7 @@ def test_get(client: BasicClient): result = client.get(id=1) assert result == VALID_USER + def test_list(client: BasicClient): result = list( client.list( @@ -54,6 +56,7 @@ def test_list(client: BasicClient): assert result[1].orders[0].user_id == 2 assert result[1].orders[0].detail == "a TV" + def _list_with_page_tests(pager: Iterable[models.User]): result = list(pager) assert len(result) == 1 @@ -62,6 +65,7 @@ def _list_with_page_tests(pager: Iterable[models.User]): assert result[0].etag == "11bdc430-65e8-45ad-81d9-8ffa60d55b59" assert result[0].orders is None + def test_list_with_page(client: BasicClient): _list_with_page_tests(client.list_with_page()) @@ -80,11 +84,13 @@ def test_export(client: BasicClient): result = client.export(id=1, format="json") assert result == VALID_USER + def test_list_with_parameters(client: BasicClient): result = list(client.list_with_parameters(models.ListItemInputBody(input_name="Madge"), another="Second")) assert len(result) == 1 assert result[0] == VALID_USER + def test_two_models_as_page_item(client: BasicClient): result = list(client.two_models_as_page_item.list_first_item()) assert len(result) == 1 diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_rpc.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_rpc.py index 4b4a5d95004..094f58b7747 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_rpc.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_rpc.py @@ -12,6 +12,9 @@ def client(): with RpcClient() as client: yield client + def test_long_running_rpc(client: RpcClient, polling_method): - result = client.begin_long_running_rpc(models.GenerationOptions(prompt="text"), polling_interval=0, polling=polling_method).result() + result = client.begin_long_running_rpc( + models.GenerationOptions(prompt="text"), polling_interval=0, polling=polling_method + ).result() assert result == models.GenerationResult(data="text data") diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_standard.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_standard.py index 53f12b23110..c9337e93fad 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_standard.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_lro_standard.py @@ -7,20 +7,26 @@ from specs.azure.core.lro.standard import StandardClient from specs.azure.core.lro.standard.models import User, ExportedUser + @pytest.fixture def client(): with StandardClient() as client: yield client + def test_lro_core_put(client, polling_method): user = User({"name": "madge", "role": "contributor"}) - result = client.begin_create_or_replace(name=user.name, resource=user, polling_interval=0, polling=polling_method).result() + result = client.begin_create_or_replace( + name=user.name, resource=user, polling_interval=0, polling=polling_method + ).result() assert result == user + def test_lro_core_delete(client, polling_method): client.begin_delete(name="madge", polling_interval=0, polling=polling_method).result() + def test_lro_core_export(client, polling_method): - export_user = ExportedUser({ "name": "madge", "resourceUri": "/users/madge" }) + export_user = ExportedUser({"name": "madge", "resourceUri": "/users/madge"}) result = client.begin_export(name="madge", format="json", polling_interval=0, polling=polling_method).result() assert result == export_user diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_scalar.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_scalar.py index 7f997c21fb8..1bca122b363 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_scalar.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_scalar.py @@ -23,9 +23,7 @@ def test_azure_location_scalar_put(client: ScalarClient): def test_azure_location_scalar_post(client: ScalarClient): - result = client.azure_location_scalar.post( - models.AzureLocationModel(location="eastus") - ) + result = client.azure_location_scalar.post(models.AzureLocationModel(location="eastus")) assert result == models.AzureLocationModel(location="eastus") diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_traits.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_traits.py index 626be3375eb..982931efb59 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_traits.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_core_traits.py @@ -25,12 +25,8 @@ def assert_test_get(**kwargs): result, header = client.smoke_test( id=1, foo="123", - if_unmodified_since=datetime( - year=2022, month=8, day=26, hour=14, minute=38, second=0 - ), - if_modified_since=datetime( - year=2021, month=8, day=26, hour=14, minute=38, second=0 - ), + if_unmodified_since=datetime(year=2022, month=8, day=26, hour=14, minute=38, second=0), + if_modified_since=datetime(year=2021, month=8, day=26, hour=14, minute=38, second=0), cls=lambda x, y, z: (y, z), raw_request_hook=functools.partial( check_client_request_id_header, header="x-ms-client-request-id", checked=checked @@ -48,6 +44,7 @@ def assert_test_get(**kwargs): with pytest.raises(HttpResponseError): assert_test_get() + def test_repeatable_action(client: TraitsClient, check_repeatability_header): result, header = client.repeatable_action( id=1, diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_special_headers_client_request_id.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_special_headers_client_request_id.py index b67151e8731..5a67d578f1a 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_special_headers_client_request_id.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_special_headers_client_request_id.py @@ -25,8 +25,5 @@ def test_get(client: XmsClientRequestIdClient, check_client_request_id_header): ), ) assert result is None - assert ( - resp.http_response.headers["x-ms-client-request-id"] - == checked["x-ms-client-request-id"] - ) + assert resp.http_response.headers["x-ms-client-request-id"] == checked["x-ms-client-request-id"] pass diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_mgmt_models_mode.py b/packages/typespec-python/test/azure/mock_api_tests/test_mgmt_models_mode.py index 1ee80b57db2..3fce5d43e92 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_mgmt_models_mode.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_mgmt_models_mode.py @@ -19,8 +19,9 @@ def test_client_signature(): assert signatures["base_url"].default == "https://management.azure.com" + def test_model_mode(): from azure.mgmt.spheredpg import _model_base from azure.mgmt.spheredpg.models import ArmResource as ArmResourceDpg - assert isinstance(ArmResourceDpg(id="", type=""), _model_base.Model) + assert isinstance(ArmResourceDpg(id="", type=""), _model_base.Model) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_duration_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_duration_async.py index 7a882ad6519..595fcaadf90 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_duration_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_encode_duration_async.py @@ -29,6 +29,7 @@ async def test_query(client: DurationClient): await client.query.int32_seconds(input=36) await client.query.int32_seconds_array(input=[36, 47]) await client.query.float_seconds(input=35.621) + await client.query.float64_seconds(input=35.621) @pytest.mark.asyncio @@ -45,6 +46,8 @@ async def test_property(client: DurationClient): assert result.value == 36 result = await client.property.float_seconds(FloatSecondsDurationProperty(value=35.621)) assert abs(result.value - 35.621) < 0.0001 + result = await client.property.float64_seconds(FloatSecondsDurationProperty(value=35.621)) + assert abs(result.value - 35.621) < 0.0001 result = await client.property.float_seconds_array(FloatSecondsDurationArrayProperty(value=[35.621, 46.781])) assert abs(result.value[0] - 35.621) < 0.0001 assert abs(result.value[1] - 46.781) < 0.0001 @@ -57,3 +60,4 @@ async def test_header(client: DurationClient): await client.header.iso8601_array(duration=[datetime.timedelta(days=40), datetime.timedelta(days=50)]) await client.header.int32_seconds(duration=36) await client.header.float_seconds(duration=35.621) + await client.header.float64_seconds(duration=35.621) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_spread_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_spread_async.py index 0eb7e1311c3..063a9d7b287 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_spread_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_parameters_spread_async.py @@ -21,30 +21,22 @@ async def test_model_body(client: SpreadClient): @pytest.mark.asyncio async def test_model_composite_request_only_with_body(client: SpreadClient): - await client.model.spread_composite_request_only_with_body( - BodyParameter(name="foo") - ) + await client.model.spread_composite_request_only_with_body(BodyParameter(name="foo")) @pytest.mark.asyncio async def test_model_composite_request_without_body(client: SpreadClient): - await client.model.spread_composite_request_without_body( - name="foo", test_header="bar" - ) + await client.model.spread_composite_request_without_body(name="foo", test_header="bar") @pytest.mark.asyncio async def test_model_composite_request(client: SpreadClient): - await client.model.spread_composite_request( - name="foo", body=BodyParameter(name="foo"), test_header="bar" - ) + await client.model.spread_composite_request(name="foo", body=BodyParameter(name="foo"), test_header="bar") @pytest.mark.asyncio async def test_model_composite_request_mix(client: SpreadClient): - await client.model.spread_composite_request_mix( - name="foo", body=CompositeRequestMix(prop="foo"), test_header="bar" - ) + await client.model.spread_composite_request_mix(name="foo", body=CompositeRequestMix(prop="foo"), test_header="bar") @pytest.mark.asyncio diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_multipart_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_multipart_async.py index 9fe080c327f..672327d6d8c 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_multipart_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_multipart_async.py @@ -106,3 +106,8 @@ async def test_multi_binary_parts(client: MultiPartClient): picture=open(str(PNG), "rb"), ) ) + await client.form_data.multi_binary_parts( + models.MultiBinaryPartsRequest( + profile_image=open(str(JPG), "rb"), + ) + ) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_resiliency_srv_driven_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_resiliency_srv_driven_async.py index 3ac2e70ce50..a74e6805fb0 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_resiliency_srv_driven_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_resiliency_srv_driven_async.py @@ -10,13 +10,17 @@ def get_v1_client(service_deployment_version: str, api_version: str = "v1") -> V1Client: return V1Client( - endpoint="http://localhost:3000", service_deployment_version=service_deployment_version, api_version=api_version + endpoint="http://localhost:3000", + service_deployment_version=service_deployment_version, + api_version=api_version, ) def get_v2_client(service_deployment_version: str, api_version: str = "v2") -> V2Client: return V2Client( - endpoint="http://localhost:3000", service_deployment_version=service_deployment_version, api_version=api_version + endpoint="http://localhost:3000", + service_deployment_version=service_deployment_version, + api_version=api_version, ) @@ -31,7 +35,11 @@ async def test_add_optional_param_from_none(): await client.from_none() # new client to new service with api version v1 - async with V2Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v1") as client: + async with V2Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v1", + ) as client: await client.from_none() # new client to new service with api version v2 @@ -50,7 +58,11 @@ async def test_add_optional_param_from_one_required(): await client.from_one_required(parameter="required") # new client to new service with api version v1 - async with V2Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v1") as client: + async with V2Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v1", + ) as client: await client.from_one_required(parameter="required") # new client to new service with api version v2 @@ -69,7 +81,11 @@ async def test_add_optional_param_from_one_optional(): await client.from_one_optional(parameter="optional") # new client to new service with api version v1 - async with V2Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v1") as client: + async with V2Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v1", + ) as client: await client.from_one_optional(parameter="optional") # new client to new service with api version v2 @@ -80,7 +96,11 @@ async def test_add_optional_param_from_one_optional(): @pytest.mark.asyncio async def test_break_the_glass(core_library): request = core_library.rest.HttpRequest(method="DELETE", url="/add-operation") - async with V1Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v2") as client: + async with V1Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v2", + ) as client: response = await client.send_request(request) response.raise_for_status() diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_flatten_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_flatten_async.py index 0f19a30ab63..5fc4b7fc92b 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_flatten_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_flatten_async.py @@ -5,7 +5,12 @@ # -------------------------------------------------------------------------- import pytest from typetest.model.flatten.aio import FlattenClient -from typetest.model.flatten.models import FlattenModel, ChildModel, NestedFlattenModel, ChildFlattenModel +from typetest.model.flatten.models import ( + FlattenModel, + ChildModel, + NestedFlattenModel, + ChildFlattenModel, +) @pytest.fixture @@ -32,10 +37,12 @@ async def test_put_nested_flatten_model(client: FlattenClient): # python doesn't support nested flatten model assert await client.put_nested_flatten_model( NestedFlattenModel( - name="foo", properties=ChildFlattenModel(summary="bar", properties=ChildModel(age=10, description="test")) + name="foo", + properties=ChildFlattenModel(summary="bar", properties=ChildModel(age=10, description="test")), ) ) == NestedFlattenModel( - name="test", properties=ChildFlattenModel(summary="test", properties=ChildModel(age=1, description="foo")) + name="test", + properties=ChildFlattenModel(summary="test", properties=ChildModel(age=1, description="foo")), ) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_enum_discriminator_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_enum_discriminator_async.py index 62493919cb8..f18c3787444 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_enum_discriminator_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_enum_discriminator_async.py @@ -36,12 +36,16 @@ async def test_put_extensible_model(client: EnumDiscriminatorClient, valid_body: @pytest.mark.asyncio -async def test_get_extensible_model_missing_discriminator(client: EnumDiscriminatorClient): +async def test_get_extensible_model_missing_discriminator( + client: EnumDiscriminatorClient, +): assert await client.get_extensible_model_missing_discriminator() == models.Dog(weight=10) @pytest.mark.asyncio -async def test_get_extensible_model_wrong_discriminator(client: EnumDiscriminatorClient): +async def test_get_extensible_model_wrong_discriminator( + client: EnumDiscriminatorClient, +): assert await client.get_extensible_model_wrong_discriminator() == models.Dog(weight=8, kind="wrongKind") diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_nested_discriminator_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_nested_discriminator_async.py index 1b51d3fb82e..4de396464ec 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_nested_discriminator_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_nested_discriminator_async.py @@ -54,7 +54,10 @@ async def valid_recursive_body(): "key4": { "age": 2, "kind": "salmon", - "friends": [{"age": 1, "kind": "salmon"}, {"age": 4, "kind": "shark", "sharktype": "goblin"}], + "friends": [ + {"age": 1, "kind": "salmon"}, + {"age": 4, "kind": "shark", "sharktype": "goblin"}, + ], }, }, } diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_recursive_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_recursive_async.py index b1f8272d2ae..aea6f1bb9e3 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_recursive_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_model_inheritance_recursive_async.py @@ -16,7 +16,12 @@ async def client(): @pytest.fixture async def expected(): - return Extension({"level": 0, "extension": [{"level": 1, "extension": [{"level": 2}]}, {"level": 1}]}) + return Extension( + { + "level": 0, + "extension": [{"level": 1, "extension": [{"level": 2}]}, {"level": 1}], + } + ) @pytest.mark.asyncio diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py index 38774221391..3967a2fadc2 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_additionalproperties_async.py @@ -67,7 +67,10 @@ async def test_extends_model(client: AdditionalPropertiesClient): @pytest.mark.asyncio async def test_extends_model_array(client: AdditionalPropertiesClient): body = models.ExtendsModelArrayAdditionalProperties( - {"knownProp": [{"state": "ok"}, {"state": "ok"}], "prop": [{"state": "ok"}, {"state": "ok"}]} + { + "knownProp": [{"state": "ok"}, {"state": "ok"}], + "prop": [{"state": "ok"}, {"state": "ok"}], + } ) assert await client.extends_model_array.get() == body await client.extends_model_array.put(body) @@ -83,7 +86,12 @@ async def test_extends_string(client: AdditionalPropertiesClient): @pytest.mark.asyncio async def test_extends_unknown(client: AdditionalPropertiesClient): body = models.ExtendsUnknownAdditionalProperties( - {"name": "ExtendsUnknownAdditionalProperties", "prop1": 32, "prop2": True, "prop3": "abc"} + { + "name": "ExtendsUnknownAdditionalProperties", + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert await client.extends_unknown.get() == body await client.extends_unknown.put(body) @@ -108,7 +116,15 @@ async def test_extends_unknown_derived(client: AdditionalPropertiesClient): @pytest.mark.asyncio async def test_extends_unknown_discriminated(client: AdditionalPropertiesClient): body = models.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( - {"kind": "derived", "name": "Derived", "index": 314, "age": 2.71828, "prop1": 32, "prop2": True, "prop3": "abc"} + { + "kind": "derived", + "name": "Derived", + "index": 314, + "age": 2.71828, + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert await client.extends_unknown_discriminated.get() == body await client.extends_unknown_discriminated.put(body) @@ -131,7 +147,10 @@ async def test_is_model(client: AdditionalPropertiesClient): @pytest.mark.asyncio async def test_is_model_array(client: AdditionalPropertiesClient): body = models.IsModelArrayAdditionalProperties( - {"knownProp": [{"state": "ok"}, {"state": "ok"}], "prop": [{"state": "ok"}, {"state": "ok"}]} + { + "knownProp": [{"state": "ok"}, {"state": "ok"}], + "prop": [{"state": "ok"}, {"state": "ok"}], + } ) assert await client.is_model_array.get() == body await client.is_model_array.put(body) @@ -147,7 +166,12 @@ async def test_is_string(client: AdditionalPropertiesClient): @pytest.mark.asyncio async def test_is_unknown(client: AdditionalPropertiesClient): body = models.IsUnknownAdditionalProperties( - {"name": "IsUnknownAdditionalProperties", "prop1": 32, "prop2": True, "prop3": "abc"} + { + "name": "IsUnknownAdditionalProperties", + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert await client.is_unknown.get() == body await client.is_unknown.put(body) @@ -172,7 +196,15 @@ async def test_is_unknown_derived(client: AdditionalPropertiesClient): @pytest.mark.asyncio async def test_is_unknown_discriminated(client: AdditionalPropertiesClient): body = models.IsUnknownAdditionalPropertiesDiscriminatedDerived( - {"kind": "derived", "name": "Derived", "index": 314, "age": 2.71828, "prop1": 32, "prop2": True, "prop3": "abc"} + { + "kind": "derived", + "name": "Derived", + "index": 314, + "age": 2.71828, + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert await client.is_unknown_discriminated.get() == body await client.is_unknown_discriminated.put(body) @@ -222,7 +254,10 @@ async def test_spread_model(client: AdditionalPropertiesClient): @pytest.mark.asyncio async def test_spread_model_array(client: AdditionalPropertiesClient): - body = {"knownProp": [{"state": "ok"}, {"state": "ok"}], "prop": [{"state": "ok"}, {"state": "ok"}]} + body = { + "knownProp": [{"state": "ok"}, {"state": "ok"}], + "prop": [{"state": "ok"}, {"state": "ok"}], + } assert await client.spread_model_array.get() == body await client.spread_model_array.put(body) @@ -232,43 +267,65 @@ async def test_spread_record_discriminated_union(client: AdditionalPropertiesCli body = { "name": "abc", "prop1": {"fooProp": "abc", "kind": "kind0"}, - "prop2": {"end": "2021-01-02T00:00:00Z", "kind": "kind1", "start": "2021-01-01T00:00:00Z"}, + "prop2": { + "end": "2021-01-02T00:00:00Z", + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + }, } assert await client.spread_record_discriminated_union.get() == body await client.spread_record_discriminated_union.put(body) @pytest.mark.asyncio -async def test_spread_record_non_discriminated_union(client: AdditionalPropertiesClient): +async def test_spread_record_non_discriminated_union( + client: AdditionalPropertiesClient, +): body = { "name": "abc", "prop1": {"kind": "kind0", "fooProp": "abc"}, - "prop2": {"kind": "kind1", "start": "2021-01-01T00:00:00Z", "end": "2021-01-02T00:00:00Z"}, + "prop2": { + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + "end": "2021-01-02T00:00:00Z", + }, } assert await client.spread_record_non_discriminated_union.get() == body await client.spread_record_non_discriminated_union.put(body) @pytest.mark.asyncio -async def test_spread_record_non_discriminated_union2(client: AdditionalPropertiesClient): +async def test_spread_record_non_discriminated_union2( + client: AdditionalPropertiesClient, +): body = { "name": "abc", "prop1": {"kind": "kind1", "start": "2021-01-01T00:00:00Z"}, - "prop2": {"kind": "kind1", "start": "2021-01-01T00:00:00Z", "end": "2021-01-02T00:00:00Z"}, + "prop2": { + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + "end": "2021-01-02T00:00:00Z", + }, } assert await client.spread_record_non_discriminated_union2.get() == body await client.spread_record_non_discriminated_union2.put(body) @pytest.mark.asyncio -async def test_spread_record_non_discriminated_union3(client: AdditionalPropertiesClient): +async def test_spread_record_non_discriminated_union3( + client: AdditionalPropertiesClient, +): body = { "name": "abc", "prop1": [ {"kind": "kind1", "start": "2021-01-01T00:00:00Z"}, {"kind": "kind1", "start": "2021-01-01T00:00:00Z"}, ], - "prop2": {"kind": "kind1", "start": "2021-01-01T00:00:00Z", "end": "2021-01-02T00:00:00Z"}, + "prop2": { + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + "end": "2021-01-02T00:00:00Z", + }, } assert await client.spread_record_non_discriminated_union3.get() == body await client.spread_record_non_discriminated_union3.put(body) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py index d9f09eeb8b4..ee66bc278a7 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py @@ -37,7 +37,8 @@ async def test_bytes(client: NullableClient): @pytest.mark.asyncio async def test_collections_byte(client: NullableClient): non_null_model = models.CollectionsByteProperty( - required_property="foo", nullable_property=["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="] + required_property="foo", + nullable_property=["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="], ) non_model = models.CollectionsByteProperty(required_property="foo", nullable_property=NULL) assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_optional_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_optional_async.py index 67258328547..36f32184d2a 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_optional_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_optional_async.py @@ -45,7 +45,10 @@ async def test_collections_byte(client): @pytest.mark.asyncio async def test_collections_model(client): body = models.CollectionsModelProperty( - property=[models.StringProperty(property="hello"), models.StringProperty(property="world")] + property=[ + models.StringProperty(property="hello"), + models.StringProperty(property="world"), + ] ) assert await client.collections_model.get_all() == body assert await client.collections_model.get_default() == models.CollectionsModelProperty() diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_valuetypes_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_valuetypes_async.py index 16c3150d8cb..9b3dcec5a31 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_valuetypes_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_typetest_property_valuetypes_async.py @@ -21,6 +21,8 @@ async def client(): async def test_model_deserialization(client: ValueTypesClient): body = models.ModelProperty(property={"property": "hello"}) assert body.property.property == body["property"]["property"] + await client.model.put(body) + resp = await client.model.get() assert resp.property.property == resp["property"]["property"] @@ -42,6 +44,8 @@ async def test_enum_property(): async def test_boolean(client: ValueTypesClient): body = models.BooleanProperty(property=True) assert body.property == body["property"] + await client.boolean.put(body) + resp = await client.boolean.get() assert resp.property == resp["property"] == True @@ -50,6 +54,8 @@ async def test_boolean(client: ValueTypesClient): async def test_boolean_literal(client: ValueTypesClient): body = models.BooleanLiteralProperty(property=True) assert body.property == body["property"] + await client.boolean_literal.put(body) + resp = await client.boolean_literal.get() assert resp.property == resp["property"] == True @@ -59,6 +65,8 @@ async def test_bytes(client: ValueTypesClient): body = models.BytesProperty(property=b"hello, world!") assert body.property == b"hello, world!" assert body["property"] == "aGVsbG8sIHdvcmxkIQ==" + await client.bytes.put(body) + resp = await client.bytes.get() assert resp.property == b"hello, world!" assert resp["property"] == "aGVsbG8sIHdvcmxkIQ==" @@ -84,6 +92,8 @@ async def test_collections_model(client: ValueTypesClient): async def test_collections_string(client: ValueTypesClient): body = models.CollectionsStringProperty(property=["hello", "world"]) assert body.property == body["property"] + await client.collections_string.put(body) + resp = await client.collections_string.get() assert resp.property == resp["property"] == ["hello", "world"] @@ -97,6 +107,7 @@ async def test_datetime(client): assert received_body.property.day == 26 assert received_body.property.hour == 18 assert received_body.property.minute == 38 + await client.datetime.put(models.DatetimeProperty(property=datetime.datetime(2022, 8, 26, hour=18, minute=38))) @@ -105,6 +116,8 @@ async def test_decimal(client: ValueTypesClient): body = models.DecimalProperty(property=decimal.Decimal("0.33333")) assert body.property == decimal.Decimal("0.33333") assert body["property"] == 0.33333 + await client.decimal.put(body) + resp = await client.decimal.get() assert resp.property == decimal.Decimal("0.33333") assert resp["property"] == 0.33333 @@ -115,6 +128,8 @@ async def test_decimal128(client: ValueTypesClient): body = models.Decimal128Property(property=decimal.Decimal("0.33333")) assert body.property == decimal.Decimal("0.33333") assert body["property"] == 0.33333 + await client.decimal128.put(body) + resp = await client.decimal128.get() assert resp.property == decimal.Decimal("0.33333") assert resp["property"] == 0.33333 @@ -124,6 +139,8 @@ async def test_decimal128(client: ValueTypesClient): async def test_dictionary_string(client: ValueTypesClient): body = models.DictionaryStringProperty(property={"k1": "hello", "k2": "world"}) assert body.property == body["property"] + await client.dictionary_string.put(body) + resp = await client.dictionary_string.get() assert resp.property == resp["property"] == {"k1": "hello", "k2": "world"} @@ -133,6 +150,8 @@ async def test_duration(client: ValueTypesClient): body = models.DurationProperty(property="P123DT22H14M12.011S") assert body.property == datetime.timedelta(days=123, seconds=80052, microseconds=11000) assert body["property"] == "P123DT22H14M12.011S" + await client.duration.put(body) + resp = await client.duration.get() assert resp.property == datetime.timedelta(days=123, seconds=80052, microseconds=11000) assert resp["property"] == "P123DT22H14M12.011S" @@ -142,6 +161,8 @@ async def test_duration(client: ValueTypesClient): async def test_enum(client: ValueTypesClient): body = models.EnumProperty(property=models.InnerEnum.VALUE_ONE) assert body.property == body["property"] + await client.enum.put(body) + resp = await client.enum.get() assert resp.property == resp["property"] == "ValueOne" @@ -150,6 +171,8 @@ async def test_enum(client: ValueTypesClient): async def test_extensible_enum(client: ValueTypesClient): body = models.ExtensibleEnumProperty(property="UnknownValue") assert body.property == body["property"] + await client.extensible_enum.put(body) + resp = await client.extensible_enum.get() assert resp.property == resp["property"] == "UnknownValue" @@ -158,6 +181,8 @@ async def test_extensible_enum(client: ValueTypesClient): async def test_float(client: ValueTypesClient): body = models.FloatProperty(property=43.125) assert body.property == body["property"] + await client.float.put(body) + resp = await client.float.get() assert resp.property == resp["property"] == 43.125 @@ -166,6 +191,8 @@ async def test_float(client: ValueTypesClient): async def test_float_literal(client: ValueTypesClient): body = models.FloatLiteralProperty(property=43.125) assert body.property == body["property"] + await client.float_literal.put(body) + resp = await client.float_literal.get() assert resp.property == resp["property"] == 43.125 @@ -174,6 +201,8 @@ async def test_float_literal(client: ValueTypesClient): async def test_int(client: ValueTypesClient): body = models.IntProperty(property=42) assert body.property == body["property"] + await client.int_operations.put(body) + resp = await client.int_operations.get() assert resp.property == resp["property"] == 42 @@ -182,6 +211,8 @@ async def test_int(client: ValueTypesClient): async def test_int_literal(client: ValueTypesClient): body = models.IntLiteralProperty(property=42) assert body.property == body["property"] + await client.int_literal.put(body) + resp = await client.int_literal.get() assert resp.property == resp["property"] == 42 @@ -190,6 +221,8 @@ async def test_int_literal(client: ValueTypesClient): async def test_model(client: ValueTypesClient): body = models.ModelProperty(property={"property": "hello"}) assert body.property.property == body["property"]["property"] + await client.model.put(body) + resp = await client.model.get() assert resp.property.property == resp["property"]["property"] @@ -204,6 +237,8 @@ async def test_never(client: ValueTypesClient): async def test_string(client: ValueTypesClient): body = models.StringProperty(property="hello") assert body.property == body["property"] + await client.string.put(body) + resp = await client.string.get() assert resp.property == resp["property"] == "hello" @@ -212,6 +247,8 @@ async def test_string(client: ValueTypesClient): async def test_string_literal(client: ValueTypesClient): body = models.StringLiteralProperty(property="hello") assert body.property == body["property"] + await client.string_literal.put(body) + resp = await client.string_literal.get() assert resp.property == resp["property"] == "hello" @@ -220,6 +257,8 @@ async def test_string_literal(client: ValueTypesClient): async def test_union_enum_value(client: ValueTypesClient): body = models.UnionEnumValueProperty(property=models.ExtendedEnum.ENUM_VALUE2) assert body.property == body["property"] + await client.union_enum_value.put(body) + resp = await client.union_enum_value.get() assert resp.property == resp["property"] == "value2" @@ -228,6 +267,8 @@ async def test_union_enum_value(client: ValueTypesClient): async def test_union_float_literal(client: ValueTypesClient): body = models.UnionFloatLiteralProperty(property=46.875) assert body.property == body["property"] + await client.union_float_literal.put(body) + resp = await client.union_float_literal.get() assert resp.property == resp["property"] == 46.875 @@ -236,6 +277,8 @@ async def test_union_float_literal(client: ValueTypesClient): async def test_union_int_literal(client: ValueTypesClient): body = models.UnionIntLiteralProperty(property=42) assert body.property == body["property"] + await client.union_int_literal.put(body) + resp = await client.union_int_literal.get() assert resp.property == resp["property"] == 42 @@ -244,6 +287,8 @@ async def test_union_int_literal(client: ValueTypesClient): async def test_union_string_literal(client: ValueTypesClient): body = models.UnionStringLiteralProperty(property="world") assert body.property == body["property"] + await client.union_string_literal.put(body) + resp = await client.union_string_literal.get() assert resp.property == resp["property"] == "world" @@ -252,6 +297,8 @@ async def test_union_string_literal(client: ValueTypesClient): async def test_unknown_array(client: ValueTypesClient): body = models.UnknownArrayProperty(property=["hello", "world"]) assert body.property == body["property"] + await client.unknown_array.put(body) + resp = await client.unknown_array.get() assert resp.property == resp["property"] == ["hello", "world"] @@ -260,6 +307,8 @@ async def test_unknown_array(client: ValueTypesClient): async def test_unknown_dict(client: ValueTypesClient): body = models.UnknownDictProperty(property={"k1": "hello", "k2": 42}) assert body.property == body["property"] + await client.unknown_dict.put(body) + resp = await client.unknown_dict.get() assert resp.property == resp["property"] == {"k1": "hello", "k2": 42} @@ -268,6 +317,8 @@ async def test_unknown_dict(client: ValueTypesClient): async def test_unknown_int(client: ValueTypesClient): body = models.UnknownIntProperty(property=42) assert body.property == body["property"] + await client.unknown_int.put(body) + resp = await client.unknown_int.get() assert resp.property == resp["property"] == 42 @@ -276,5 +327,7 @@ async def test_unknown_int(client: ValueTypesClient): async def test_unknown_string(client: ValueTypesClient): body = models.UnknownStringProperty(property="hello") assert body.property == body["property"] + await client.unknown_string.put(body) + resp = await client.unknown_string.get() assert resp.property == resp["property"] == "hello" diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_added_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_added_async.py index 03c60e2e246..27e78a8892d 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_added_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_added_async.py @@ -24,9 +24,9 @@ async def test_v1(client: AddedClient): @pytest.mark.asyncio async def test_v2(client: AddedClient): - assert await client.v2( - ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") - ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") + assert await client.v2(ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar")) == ModelV2( + prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar" + ) @pytest.mark.asyncio diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_made_optional_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_made_optional_async.py index a2dd4fa1f8b..27ec811cae2 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_made_optional_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_made_optional_async.py @@ -10,9 +10,7 @@ @pytest.fixture async def client(): - async with MadeOptionalClient( - endpoint="http://localhost:3000", version="v2" - ) as client: + async with MadeOptionalClient(endpoint="http://localhost:3000", version="v2") as client: yield client diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py index 77aa2611dee..1ec75c52298 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py @@ -16,6 +16,6 @@ async def client(): @pytest.mark.asyncio async def test_v2(client: RemovedClient): - assert await client.v2( - ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar") - ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar") + assert await client.v2(ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar")) == ModelV2( + prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar" + ) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_renamed_from_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_renamed_from_async.py index 7204ada9973..46ef588f65d 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_renamed_from_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_renamed_from_async.py @@ -10,9 +10,7 @@ @pytest.fixture async def client(): - async with RenamedFromClient( - endpoint="http://localhost:3000", version="v2" - ) as client: + async with RenamedFromClient(endpoint="http://localhost:3000", version="v2") as client: yield client diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_return_type_changed_from_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_return_type_changed_from_async.py index 29f211cd865..80eefecbe22 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_return_type_changed_from_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_return_type_changed_from_async.py @@ -9,9 +9,7 @@ @pytest.fixture async def client(): - async with ReturnTypeChangedFromClient( - endpoint="http://localhost:3000", version="v2" - ) as client: + async with ReturnTypeChangedFromClient(endpoint="http://localhost:3000", version="v2") as client: yield client diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_type_changed_from_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_type_changed_from_async.py index 71516196540..2374bd1f550 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_type_changed_from_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_versioning_type_changed_from_async.py @@ -10,9 +10,7 @@ @pytest.fixture async def client(): - async with TypeChangedFromClient( - endpoint="http://localhost:3000", version="v2" - ) as client: + async with TypeChangedFromClient(endpoint="http://localhost:3000", version="v2") as client: yield client diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_encode_duration.py b/packages/typespec-python/test/generic_mock_api_tests/test_encode_duration.py index affb841462b..70aa2b43550 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_encode_duration.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_encode_duration.py @@ -28,6 +28,7 @@ def test_query(client: DurationClient): client.query.int32_seconds(input=36) client.query.int32_seconds_array(input=[36, 47]) client.query.float_seconds(input=35.621) + client.query.float64_seconds(input=35.621) def test_property(client: DurationClient): @@ -43,6 +44,8 @@ def test_property(client: DurationClient): assert result.value == 36 result = client.property.float_seconds(FloatSecondsDurationProperty(value=35.621)) assert abs(result.value - 35.621) < 0.0001 + result = client.property.float64_seconds(FloatSecondsDurationProperty(value=35.621)) + assert abs(result.value - 35.621) < 0.0001 result = client.property.float_seconds_array(FloatSecondsDurationArrayProperty(value=[35.621, 46.781])) assert abs(result.value[0] - 35.621) < 0.0001 assert abs(result.value[1] - 46.781) < 0.0001 @@ -54,3 +57,4 @@ def test_header(client: DurationClient): client.header.iso8601_array(duration=[datetime.timedelta(days=40), datetime.timedelta(days=50)]) client.header.int32_seconds(duration=36) client.header.float_seconds(duration=35.621) + client.header.float64_seconds(duration=35.621) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_parameters_spread.py b/packages/typespec-python/test/generic_mock_api_tests/test_parameters_spread.py index 6eea2bc48fe..ebc4766d0ec 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_parameters_spread.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_parameters_spread.py @@ -27,15 +27,11 @@ def test_model_composite_request_without_body(client: SpreadClient): def test_model_composite_request(client: SpreadClient): - client.model.spread_composite_request( - name="foo", body=BodyParameter(name="foo"), test_header="bar" - ) + client.model.spread_composite_request(name="foo", body=BodyParameter(name="foo"), test_header="bar") def test_model_composite_request_mix(client: SpreadClient): - client.model.spread_composite_request_mix( - name="foo", body=CompositeRequestMix(prop="foo"), test_header="bar" - ) + client.model.spread_composite_request_mix(name="foo", body=CompositeRequestMix(prop="foo"), test_header="bar") def test_alias_body(client: SpreadClient): diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_payload_multipart.py b/packages/typespec-python/test/generic_mock_api_tests/test_payload_multipart.py index 370a81ec630..b65ffd02580 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_payload_multipart.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_payload_multipart.py @@ -97,3 +97,8 @@ def test_multi_binary_parts(client: MultiPartClient): picture=open(str(PNG), "rb"), ) ) + client.form_data.multi_binary_parts( + models.MultiBinaryPartsRequest( + profile_image=open(str(JPG), "rb"), + ) + ) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_resiliency_srv_driven.py b/packages/typespec-python/test/generic_mock_api_tests/test_resiliency_srv_driven.py index f2a69c81d3b..ec411ab1b09 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_resiliency_srv_driven.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_resiliency_srv_driven.py @@ -10,13 +10,17 @@ def get_v1_client(service_deployment_version: str, api_version: str = "v1") -> V1Client: return V1Client( - endpoint="http://localhost:3000", service_deployment_version=service_deployment_version, api_version=api_version + endpoint="http://localhost:3000", + service_deployment_version=service_deployment_version, + api_version=api_version, ) def get_v2_client(service_deployment_version: str, api_version: str = "v2") -> V2Client: return V2Client( - endpoint="http://localhost:3000", service_deployment_version=service_deployment_version, api_version=api_version + endpoint="http://localhost:3000", + service_deployment_version=service_deployment_version, + api_version=api_version, ) @@ -30,7 +34,11 @@ def test_add_optional_param_from_none(): client.from_none() # new client to new service with api version v1 - with V2Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v1") as client: + with V2Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v1", + ) as client: client.from_none() # new client to new service with api version v2 @@ -48,7 +56,11 @@ def test_add_optional_param_from_one_required(): client.from_one_required(parameter="required") # new client to new service with api version v1 - with V2Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v1") as client: + with V2Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v1", + ) as client: client.from_one_required(parameter="required") # new client to new service with api version v2 @@ -66,7 +78,11 @@ def test_add_optional_param_from_one_optional(): client.from_one_optional(parameter="optional") # new client to new service with api version v1 - with V2Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v1") as client: + with V2Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v1", + ) as client: client.from_one_optional(parameter="optional") # new client to new service with api version v2 @@ -76,7 +92,11 @@ def test_add_optional_param_from_one_optional(): def test_break_the_glass(core_library): request = core_library.rest.HttpRequest(method="DELETE", url="/add-operation") - with V1Client(endpoint="http://localhost:3000", service_deployment_version="v2", api_version="v2") as client: + with V1Client( + endpoint="http://localhost:3000", + service_deployment_version="v2", + api_version="v2", + ) as client: response = client.send_request(request) response.raise_for_status() diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_flatten.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_flatten.py index dcf2a642dd2..312f5921b46 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_flatten.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_flatten.py @@ -5,7 +5,12 @@ # -------------------------------------------------------------------------- import pytest from typetest.model.flatten import FlattenClient -from typetest.model.flatten.models import FlattenModel, ChildModel, NestedFlattenModel, ChildFlattenModel +from typetest.model.flatten.models import ( + FlattenModel, + ChildModel, + NestedFlattenModel, + ChildFlattenModel, +) @pytest.fixture @@ -27,10 +32,12 @@ def test_put_nested_flatten_model(client: FlattenClient): # python doesn't support nested flatten model assert client.put_nested_flatten_model( NestedFlattenModel( - name="foo", properties=ChildFlattenModel(summary="bar", properties=ChildModel(age=10, description="test")) + name="foo", + properties=ChildFlattenModel(summary="bar", properties=ChildModel(age=10, description="test")), ) ) == NestedFlattenModel( - name="test", properties=ChildFlattenModel(summary="test", properties=ChildModel(age=1, description="foo")) + name="test", + properties=ChildFlattenModel(summary="test", properties=ChildModel(age=1, description="foo")), ) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_nested_discriminator.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_nested_discriminator.py index 54bf5f74cf2..f903dc8fbee 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_nested_discriminator.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_nested_discriminator.py @@ -52,7 +52,10 @@ def valid_recursive_body(): "key4": { "age": 2, "kind": "salmon", - "friends": [{"age": 1, "kind": "salmon"}, {"age": 4, "kind": "shark", "sharktype": "goblin"}], + "friends": [ + {"age": 1, "kind": "salmon"}, + {"age": 4, "kind": "shark", "sharktype": "goblin"}, + ], }, }, } diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_recursive.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_recursive.py index bd810ed036d..1aa0758e34d 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_recursive.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_model_inheritance_recursive.py @@ -16,7 +16,12 @@ def client(): @pytest.fixture def expected(): - return Extension({"level": 0, "extension": [{"level": 1, "extension": [{"level": 2}]}, {"level": 1}]}) + return Extension( + { + "level": 0, + "extension": [{"level": 1, "extension": [{"level": 2}]}, {"level": 1}], + } + ) def test_put(client: RecursiveClient, expected: Extension): diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py index 8f1a26be4cb..31edad2f8dc 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_additionalproperties.py @@ -59,7 +59,10 @@ def test_extends_model(client: AdditionalPropertiesClient): def test_extends_model_array(client: AdditionalPropertiesClient): body = models.ExtendsModelArrayAdditionalProperties( - {"knownProp": [{"state": "ok"}, {"state": "ok"}], "prop": [{"state": "ok"}, {"state": "ok"}]} + { + "knownProp": [{"state": "ok"}, {"state": "ok"}], + "prop": [{"state": "ok"}, {"state": "ok"}], + } ) assert client.extends_model_array.get() == body client.extends_model_array.put(body) @@ -73,7 +76,12 @@ def test_extends_string(client: AdditionalPropertiesClient): def test_extends_unknown(client: AdditionalPropertiesClient): body = models.ExtendsUnknownAdditionalProperties( - {"name": "ExtendsUnknownAdditionalProperties", "prop1": 32, "prop2": True, "prop3": "abc"} + { + "name": "ExtendsUnknownAdditionalProperties", + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert client.extends_unknown.get() == body client.extends_unknown.put(body) @@ -96,7 +104,15 @@ def test_extends_unknown_derived(client: AdditionalPropertiesClient): def test_extends_unknown_discriminated(client: AdditionalPropertiesClient): body = models.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( - {"kind": "derived", "name": "Derived", "index": 314, "age": 2.71828, "prop1": 32, "prop2": True, "prop3": "abc"} + { + "kind": "derived", + "name": "Derived", + "index": 314, + "age": 2.71828, + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert client.extends_unknown_discriminated.get() == body client.extends_unknown_discriminated.put(body) @@ -116,7 +132,10 @@ def test_is_model(client: AdditionalPropertiesClient): def test_is_model_array(client: AdditionalPropertiesClient): body = models.IsModelArrayAdditionalProperties( - {"knownProp": [{"state": "ok"}, {"state": "ok"}], "prop": [{"state": "ok"}, {"state": "ok"}]} + { + "knownProp": [{"state": "ok"}, {"state": "ok"}], + "prop": [{"state": "ok"}, {"state": "ok"}], + } ) assert client.is_model_array.get() == body client.is_model_array.put(body) @@ -130,7 +149,12 @@ def test_is_string(client: AdditionalPropertiesClient): def test_is_unknown(client: AdditionalPropertiesClient): body = models.IsUnknownAdditionalProperties( - {"name": "IsUnknownAdditionalProperties", "prop1": 32, "prop2": True, "prop3": "abc"} + { + "name": "IsUnknownAdditionalProperties", + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert client.is_unknown.get() == body client.is_unknown.put(body) @@ -153,7 +177,15 @@ def test_is_unknown_derived(client: AdditionalPropertiesClient): def test_is_unknown_discriminated(client: AdditionalPropertiesClient): body = models.IsUnknownAdditionalPropertiesDiscriminatedDerived( - {"kind": "derived", "name": "Derived", "index": 314, "age": 2.71828, "prop1": 32, "prop2": True, "prop3": "abc"} + { + "kind": "derived", + "name": "Derived", + "index": 314, + "age": 2.71828, + "prop1": 32, + "prop2": True, + "prop3": "abc", + } ) assert client.is_unknown_discriminated.get() == body client.is_unknown_discriminated.put(body) @@ -196,7 +228,10 @@ def test_spread_model(client: AdditionalPropertiesClient): def test_spread_model_array(client: AdditionalPropertiesClient): - body = {"knownProp": [{"state": "ok"}, {"state": "ok"}], "prop": [{"state": "ok"}, {"state": "ok"}]} + body = { + "knownProp": [{"state": "ok"}, {"state": "ok"}], + "prop": [{"state": "ok"}, {"state": "ok"}], + } assert client.spread_model_array.get() == body client.spread_model_array.put(body) @@ -205,7 +240,11 @@ def test_spread_record_discriminated_union(client: AdditionalPropertiesClient): body = { "name": "abc", "prop1": {"fooProp": "abc", "kind": "kind0"}, - "prop2": {"end": "2021-01-02T00:00:00Z", "kind": "kind1", "start": "2021-01-01T00:00:00Z"}, + "prop2": { + "end": "2021-01-02T00:00:00Z", + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + }, } assert client.spread_record_discriminated_union.get() == body client.spread_record_discriminated_union.put(body) @@ -215,7 +254,11 @@ def test_spread_record_non_discriminated_union(client: AdditionalPropertiesClien body = { "name": "abc", "prop1": {"kind": "kind0", "fooProp": "abc"}, - "prop2": {"kind": "kind1", "start": "2021-01-01T00:00:00Z", "end": "2021-01-02T00:00:00Z"}, + "prop2": { + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + "end": "2021-01-02T00:00:00Z", + }, } assert client.spread_record_non_discriminated_union.get() == body client.spread_record_non_discriminated_union.put(body) @@ -225,7 +268,11 @@ def test_spread_record_non_discriminated_union2(client: AdditionalPropertiesClie body = { "name": "abc", "prop1": {"kind": "kind1", "start": "2021-01-01T00:00:00Z"}, - "prop2": {"kind": "kind1", "start": "2021-01-01T00:00:00Z", "end": "2021-01-02T00:00:00Z"}, + "prop2": { + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + "end": "2021-01-02T00:00:00Z", + }, } assert client.spread_record_non_discriminated_union2.get() == body client.spread_record_non_discriminated_union2.put(body) @@ -238,7 +285,11 @@ def test_spread_record_non_discriminated_union3(client: AdditionalPropertiesClie {"kind": "kind1", "start": "2021-01-01T00:00:00Z"}, {"kind": "kind1", "start": "2021-01-01T00:00:00Z"}, ], - "prop2": {"kind": "kind1", "start": "2021-01-01T00:00:00Z", "end": "2021-01-02T00:00:00Z"}, + "prop2": { + "kind": "kind1", + "start": "2021-01-01T00:00:00Z", + "end": "2021-01-02T00:00:00Z", + }, } assert client.spread_record_non_discriminated_union3.get() == body client.spread_record_non_discriminated_union3.put(body) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_nullable.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_nullable.py index ef784a9cb96..4c9e3d1c24c 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_nullable.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_nullable.py @@ -34,7 +34,8 @@ def test_bytes(client: NullableClient): def test_collections_byte(client: NullableClient): non_null_model = models.CollectionsByteProperty( - required_property="foo", nullable_property=["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="] + required_property="foo", + nullable_property=["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="], ) non_model = models.CollectionsByteProperty(required_property="foo", nullable_property=NULL) assert '{"requiredProperty": "foo", "nullableProperty": null}' == json.dumps(non_model, cls=SdkJSONEncoder) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_optional.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_optional.py index 5cfe4b70f92..4aa4a0faeb3 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_optional.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_optional.py @@ -40,7 +40,10 @@ def test_collections_byte(client): def test_collections_model(client): body = models.CollectionsModelProperty( - property=[models.StringProperty(property="hello"), models.StringProperty(property="world")] + property=[ + models.StringProperty(property="hello"), + models.StringProperty(property="world"), + ] ) assert client.collections_model.get_all() == body assert client.collections_model.get_default() == models.CollectionsModelProperty() diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_valuetypes.py b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_valuetypes.py index c9b19bbc6c7..a82d937612e 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_valuetypes.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_typetest_property_valuetypes.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from calendar import c import decimal import pytest @@ -19,6 +20,8 @@ def client(): def test_model_deserialization(client: ValueTypesClient): body = models.ModelProperty(property={"property": "hello"}) assert body.property.property == body["property"]["property"] + client.model.put(body) + resp = client.model.get() assert resp.property.property == resp["property"]["property"] @@ -38,6 +41,8 @@ def test_enum_property(): def test_boolean(client: ValueTypesClient): body = models.BooleanProperty(property=True) assert body.property == body["property"] + client.boolean.put(body) + resp = client.boolean.get() assert resp.property == resp["property"] == True @@ -45,6 +50,8 @@ def test_boolean(client: ValueTypesClient): def test_boolean_literal(client: ValueTypesClient): body = models.BooleanLiteralProperty(property=True) assert body.property == body["property"] + client.boolean_literal.put(body) + resp = client.boolean_literal.get() assert resp.property == resp["property"] == True @@ -53,6 +60,8 @@ def test_bytes(client: ValueTypesClient): body = models.BytesProperty(property=b"hello, world!") assert body.property == b"hello, world!" assert body["property"] == "aGVsbG8sIHdvcmxkIQ==" + client.bytes.put(body) + resp = client.bytes.get() assert resp.property == b"hello, world!" assert resp["property"] == "aGVsbG8sIHdvcmxkIQ==" @@ -75,6 +84,8 @@ def test_collections_model(client: ValueTypesClient): def test_collections_string(client: ValueTypesClient): body = models.CollectionsStringProperty(property=["hello", "world"]) assert body.property == body["property"] + client.collections_string.put(body) + resp = client.collections_string.get() assert resp.property == resp["property"] == ["hello", "world"] @@ -87,6 +98,7 @@ def test_datetime(client): assert received_body.property.day == 26 assert received_body.property.hour == 18 assert received_body.property.minute == 38 + client.datetime.put(models.DatetimeProperty(property=datetime.datetime(2022, 8, 26, hour=18, minute=38))) @@ -94,6 +106,8 @@ def test_decimal(client: ValueTypesClient): body = models.DecimalProperty(property=decimal.Decimal("0.33333")) assert body.property == decimal.Decimal("0.33333") assert body["property"] == 0.33333 + client.decimal.put(body) + resp = client.decimal.get() assert resp.property == decimal.Decimal("0.33333") assert resp["property"] == 0.33333 @@ -103,6 +117,8 @@ def test_decimal128(client: ValueTypesClient): body = models.Decimal128Property(property=decimal.Decimal("0.33333")) assert body.property == decimal.Decimal("0.33333") assert body["property"] == 0.33333 + client.decimal128.put(body) + resp = client.decimal128.get() assert resp.property == decimal.Decimal("0.33333") assert resp["property"] == 0.33333 @@ -111,6 +127,8 @@ def test_decimal128(client: ValueTypesClient): def test_dictionary_string(client: ValueTypesClient): body = models.DictionaryStringProperty(property={"k1": "hello", "k2": "world"}) assert body.property == body["property"] + client.dictionary_string.put(body) + resp = client.dictionary_string.get() assert resp.property == resp["property"] == {"k1": "hello", "k2": "world"} @@ -119,6 +137,8 @@ def test_duration(client: ValueTypesClient): body = models.DurationProperty(property="P123DT22H14M12.011S") assert body.property == datetime.timedelta(days=123, seconds=80052, microseconds=11000) assert body["property"] == "P123DT22H14M12.011S" + client.duration.put(body) + resp = client.duration.get() assert resp.property == datetime.timedelta(days=123, seconds=80052, microseconds=11000) assert resp["property"] == "P123DT22H14M12.011S" @@ -127,6 +147,8 @@ def test_duration(client: ValueTypesClient): def test_enum(client: ValueTypesClient): body = models.EnumProperty(property=models.InnerEnum.VALUE_ONE) assert body.property == body["property"] + client.enum.put(body) + resp = client.enum.get() assert resp.property == resp["property"] == "ValueOne" @@ -134,6 +156,8 @@ def test_enum(client: ValueTypesClient): def test_extensible_enum(client: ValueTypesClient): body = models.ExtensibleEnumProperty(property="UnknownValue") assert body.property == body["property"] + client.extensible_enum.put(body) + resp = client.extensible_enum.get() assert resp.property == resp["property"] == "UnknownValue" @@ -141,6 +165,8 @@ def test_extensible_enum(client: ValueTypesClient): def test_float(client: ValueTypesClient): body = models.FloatProperty(property=43.125) assert body.property == body["property"] + client.float.put(body) + resp = client.float.get() assert resp.property == resp["property"] == 43.125 @@ -148,6 +174,8 @@ def test_float(client: ValueTypesClient): def test_float_literal(client: ValueTypesClient): body = models.FloatLiteralProperty(property=43.125) assert body.property == body["property"] + client.float_literal.put(body) + resp = client.float_literal.get() assert resp.property == resp["property"] == 43.125 @@ -155,6 +183,8 @@ def test_float_literal(client: ValueTypesClient): def test_int(client: ValueTypesClient): body = models.IntProperty(property=42) assert body.property == body["property"] + client.int_operations.put(body) + resp = client.int_operations.get() assert resp.property == resp["property"] == 42 @@ -162,6 +192,8 @@ def test_int(client: ValueTypesClient): def test_int_literal(client: ValueTypesClient): body = models.IntLiteralProperty(property=42) assert body.property == body["property"] + client.int_literal.put(body) + resp = client.int_literal.get() assert resp.property == resp["property"] == 42 @@ -169,6 +201,8 @@ def test_int_literal(client: ValueTypesClient): def test_model(client: ValueTypesClient): body = models.ModelProperty(property={"property": "hello"}) assert body.property.property == body["property"]["property"] + client.model.put(body) + resp = client.model.get() assert resp.property.property == resp["property"]["property"] @@ -181,6 +215,8 @@ def test_never(client: ValueTypesClient): def test_string(client: ValueTypesClient): body = models.StringProperty(property="hello") assert body.property == body["property"] + client.string.put(body) + resp = client.string.get() assert resp.property == resp["property"] == "hello" @@ -188,6 +224,8 @@ def test_string(client: ValueTypesClient): def test_string_literal(client: ValueTypesClient): body = models.StringLiteralProperty(property="hello") assert body.property == body["property"] + client.string_literal.put(body) + resp = client.string_literal.get() assert resp.property == resp["property"] == "hello" @@ -195,6 +233,8 @@ def test_string_literal(client: ValueTypesClient): def test_union_enum_value(client: ValueTypesClient): body = models.UnionEnumValueProperty(property=models.ExtendedEnum.ENUM_VALUE2) assert body.property == body["property"] + client.union_enum_value.put(body) + resp = client.union_enum_value.get() assert resp.property == resp["property"] == "value2" @@ -202,6 +242,8 @@ def test_union_enum_value(client: ValueTypesClient): def test_union_float_literal(client: ValueTypesClient): body = models.UnionFloatLiteralProperty(property=46.875) assert body.property == body["property"] + client.union_float_literal.put(body) + resp = client.union_float_literal.get() assert resp.property == resp["property"] == 46.875 @@ -209,6 +251,8 @@ def test_union_float_literal(client: ValueTypesClient): def test_union_int_literal(client: ValueTypesClient): body = models.UnionIntLiteralProperty(property=42) assert body.property == body["property"] + client.union_int_literal.put(body) + resp = client.union_int_literal.get() assert resp.property == resp["property"] == 42 @@ -216,6 +260,8 @@ def test_union_int_literal(client: ValueTypesClient): def test_union_string_literal(client: ValueTypesClient): body = models.UnionStringLiteralProperty(property="world") assert body.property == body["property"] + client.union_string_literal.put(body) + resp = client.union_string_literal.get() assert resp.property == resp["property"] == "world" @@ -223,6 +269,8 @@ def test_union_string_literal(client: ValueTypesClient): def test_unknown_array(client: ValueTypesClient): body = models.UnknownArrayProperty(property=["hello", "world"]) assert body.property == body["property"] + client.unknown_array.put(body) + resp = client.unknown_array.get() assert resp.property == resp["property"] == ["hello", "world"] @@ -230,6 +278,8 @@ def test_unknown_array(client: ValueTypesClient): def test_unknown_dict(client: ValueTypesClient): body = models.UnknownDictProperty(property={"k1": "hello", "k2": 42}) assert body.property == body["property"] + client.unknown_dict.put(body) + resp = client.unknown_dict.get() assert resp.property == resp["property"] == {"k1": "hello", "k2": 42} @@ -237,6 +287,8 @@ def test_unknown_dict(client: ValueTypesClient): def test_unknown_int(client: ValueTypesClient): body = models.UnknownIntProperty(property=42) assert body.property == body["property"] + client.unknown_int.put(body) + resp = client.unknown_int.get() assert resp.property == resp["property"] == 42 @@ -244,5 +296,7 @@ def test_unknown_int(client: ValueTypesClient): def test_unknown_string(client: ValueTypesClient): body = models.UnknownStringProperty(property="hello") assert body.property == body["property"] + client.unknown_string.put(body) + resp = client.unknown_string.get() assert resp.property == resp["property"] == "hello" diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_added.py b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_added.py index 41a18279694..c51b159cba6 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_added.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_added.py @@ -22,9 +22,9 @@ def test_v1(client: AddedClient): def test_v2(client: AddedClient): - assert client.v2( - ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") - ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") + assert client.v2(ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar")) == ModelV2( + prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar" + ) def test_interface_v2(client: AddedClient): diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_removed.py b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_removed.py index 222225faf09..c29ed0ac25f 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_removed.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_removed.py @@ -15,6 +15,6 @@ def client(): def test_v2(client: RemovedClient): - assert client.v2( - ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar") - ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar") + assert client.v2(ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar")) == ModelV2( + prop="foo", enum_prop=EnumV2.ENUM_MEMBER_V2, union_prop="bar" + ) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_return_type_changed_from.py b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_return_type_changed_from.py index a0c1d03f425..92decc72045 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_return_type_changed_from.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_return_type_changed_from.py @@ -9,12 +9,9 @@ @pytest.fixture def client(): - with ReturnTypeChangedFromClient( - endpoint="http://localhost:3000", version="v2" - ) as client: + with ReturnTypeChangedFromClient(endpoint="http://localhost:3000", version="v2") as client: yield client def test(client: ReturnTypeChangedFromClient): assert client.test("test") == "test" - diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_type_changed_from.py b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_type_changed_from.py index 50a7816d424..e10742a8153 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_versioning_type_changed_from.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_versioning_type_changed_from.py @@ -10,9 +10,7 @@ @pytest.fixture def client(): - with TypeChangedFromClient( - endpoint="http://localhost:3000", version="v2" - ) as client: + with TypeChangedFromClient(endpoint="http://localhost:3000", version="v2") as client: yield client diff --git a/packages/typespec-python/test/generic_mock_api_tests/unittests/test_model_base_serialization.py b/packages/typespec-python/test/generic_mock_api_tests/unittests/test_model_base_serialization.py index 7a00f45c8aa..a2ef0ae0d68 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/unittests/test_model_base_serialization.py +++ b/packages/typespec-python/test/generic_mock_api_tests/unittests/test_model_base_serialization.py @@ -7,13 +7,33 @@ import json import datetime from pathlib import Path -from typing import Any, Iterable, List, Literal, Dict, Mapping, Sequence, Set, Tuple, Optional, overload, Union +from typing import ( + Any, + Iterable, + List, + Literal, + Dict, + Mapping, + Sequence, + Set, + Tuple, + Optional, + overload, + Union, +) import pytest import isodate import sys from enum import Enum -from specialwords._model_base import SdkJSONEncoder, Model, rest_field, _is_model, rest_discriminator, _deserialize +from specialwords._model_base import ( + SdkJSONEncoder, + Model, + rest_field, + _is_model, + rest_discriminator, + _deserialize, +) if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -62,8 +82,16 @@ def __init__(self, *args, **kwargs): def test_model_and_dict_equal(): - dict_response = {"platformUpdateDomainCount": 5, "platformFaultDomainCount": 3, "virtualMachines": []} - model = BasicResource(platform_update_domain_count=5, platform_fault_domain_count=3, virtual_machines=[]) + dict_response = { + "platformUpdateDomainCount": 5, + "platformFaultDomainCount": 3, + "virtualMachines": [], + } + model = BasicResource( + platform_update_domain_count=5, + platform_fault_domain_count=3, + virtual_machines=[], + ) assert model == dict_response assert ( @@ -82,8 +110,16 @@ def test_model_and_dict_equal(): def test_json_roundtrip(): - dict_response = {"platformUpdateDomainCount": 5, "platformFaultDomainCount": 3, "virtualMachines": []} - model = BasicResource(platform_update_domain_count=5, platform_fault_domain_count=3, virtual_machines=[]) + dict_response = { + "platformUpdateDomainCount": 5, + "platformFaultDomainCount": 3, + "virtualMachines": [], + } + model = BasicResource( + platform_update_domain_count=5, + platform_fault_domain_count=3, + virtual_machines=[], + ) with pytest.raises(TypeError): json.dumps(model) assert ( @@ -120,7 +156,10 @@ class BasicResourceWithProperty(BasicResource): no_prop: str = rest_field(name="noprop") model = BasicResourceWithProperty( - platform_update_domain_count=5, platform_fault_domain_count=3, virtual_machines=[], no_prop="bonjour!" + platform_update_domain_count=5, + platform_fault_domain_count=3, + virtual_machines=[], + no_prop="bonjour!", ) assert model.no_prop == model["noprop"] == dict_response["noprop"] == "bonjour!" @@ -235,7 +274,11 @@ def test_model_pass_in_none(): def test_modify_dict(): - model = BasicResource(platform_update_domain_count=5, platform_fault_domain_count=3, virtual_machines=[]) + model = BasicResource( + platform_update_domain_count=5, + platform_fault_domain_count=3, + virtual_machines=[], + ) # now let's modify the model as a dict model["platformUpdateDomainCount"] = 100 @@ -243,8 +286,16 @@ def test_modify_dict(): def test_modify_property(): - dict_response = {"platformUpdateDomainCount": 5, "platformFaultDomainCount": 3, "virtualMachines": []} - model = BasicResource(platform_update_domain_count=5, platform_fault_domain_count=3, virtual_machines=[]) + dict_response = { + "platformUpdateDomainCount": 5, + "platformFaultDomainCount": 3, + "virtualMachines": [], + } + model = BasicResource( + platform_update_domain_count=5, + platform_fault_domain_count=3, + virtual_machines=[], + ) # now let's modify the model through it's properties model.platform_fault_domain_count = 2000 @@ -520,10 +571,21 @@ def __init__(self, mapping: Mapping[str, Any], /): ... def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - dict_response = {"prop": [{"name": "Eugene", "species": "Dog"}, {"name": "Lady", "species": "Newt"}]} + dict_response = { + "prop": [ + {"name": "Eugene", "species": "Dog"}, + {"name": "Lady", "species": "Newt"}, + ] + } model = ListModel(dict_response) - assert model["prop"] == [{"name": "Eugene", "species": "Dog"}, {"name": "Lady", "species": "Newt"}] - assert model.prop == [Pet({"name": "Eugene", "species": "Dog"}), Pet({"name": "Lady", "species": "Newt"})] + assert model["prop"] == [ + {"name": "Eugene", "species": "Dog"}, + {"name": "Lady", "species": "Newt"}, + ] + assert model.prop == [ + Pet({"name": "Eugene", "species": "Dog"}), + Pet({"name": "Lady", "species": "Newt"}), + ] assert len(model.prop) == 2 assert model.prop[0].name == model.prop[0]["name"] == "Eugene" assert model.prop[0].species == model.prop[0]["species"] == "Dog" @@ -808,7 +870,12 @@ class LiteralModel(Model): age: Literal[1, 2, 3] = rest_field() @overload - def __init__(self, *, species: Literal["Mongose", "Eagle", "Penguin"], age: Literal[1, 2, 3]): ... + def __init__( + self, + *, + species: Literal["Mongose", "Eagle", "Penguin"], + age: Literal[1, 2, 3], + ): ... @overload def __init__(self, mapping: Mapping[str, Any], /): ... @@ -1168,13 +1235,23 @@ def test_inheritance_4_levels(): prop=3.4, bcd_prop=[b], cd_prop=a, - d_prop=(a, b, c, ChildD(prop=3.4, bcd_prop=[b], cd_prop=a, d_prop=(a, b, c, None))), + d_prop=( + a, + b, + c, + ChildD(prop=3.4, bcd_prop=[b], cd_prop=a, d_prop=(a, b, c, None)), + ), ) assert d == { "prop": 3.4, "bcdProp": [b], "cdProp": a, - "dProp": (a, b, c, {"prop": 3.4, "bcdProp": [b], "cdProp": a, "dProp": (a, b, c, None)}), + "dProp": ( + a, + b, + c, + {"prop": 3.4, "bcdProp": [b], "cdProp": a, "dProp": (a, b, c, None)}, + ), } assert d.prop == d["prop"] == 3.4 assert d.bcd_prop == [b] @@ -1769,7 +1846,10 @@ def test_readonly_set(): assert json.loads(json.dumps(model, cls=SdkJSONEncoder)) == { "normalProperty": "setWithDict", "readonlyProperty": "setWithDict", - "innerModel": {"normalProperty": "setWithDict", "readonlyProperty": "setWithDict"}, + "innerModel": { + "normalProperty": "setWithDict", + "readonlyProperty": "setWithDict", + }, } @@ -1922,7 +2002,12 @@ def __init__(self, *args, **kwargs): assert my_model.prop_optional_str is my_model["propOptionalStr"] is None assert my_model.prop_default_int == my_model["propDefaultInt"] == 1 assert my_model.prop_optional_int == my_model["propOptionalInt"] == 4 - assert my_model == {"propDefaultStr": "hello", "propOptionalStr": None, "propDefaultInt": 1, "propOptionalInt": 4} + assert my_model == { + "propDefaultStr": "hello", + "propOptionalStr": None, + "propDefaultInt": 1, + "propOptionalInt": 4, + } my_model = MyModel({"propDefaultInt": 5}) assert my_model.prop_default_str == my_model["propDefaultStr"] == "hello" @@ -2041,7 +2126,12 @@ def __init__(self, mapping: Mapping[str, Any], /): ... def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - original_dict = {"middleProperty": {"innerProperty": [{"strProperty": "hello"}], "prop": "original"}} + original_dict = { + "middleProperty": { + "innerProperty": [{"strProperty": "hello"}], + "prop": "original", + } + } model = Outer(original_dict) assert model is not original_dict @@ -2139,7 +2229,12 @@ def __init__(self, mapping: Mapping[str, Any], /): ... def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - original_dict = {"middleProperty": {"innerProperty": {"inner": {"strProperty": "hello"}}, "prop": "original"}} + original_dict = { + "middleProperty": { + "innerProperty": {"inner": {"strProperty": "hello"}}, + "prop": "original", + } + } model = Outer(original_dict) assert model is not original_dict @@ -2278,7 +2373,12 @@ def __init__(self, mapping: Mapping[str, Any], /): ... def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - original_dict = {"middleProperty": {"innerProperty": {"inner": {"strProperty": "hello"}}, "prop": "original"}} + original_dict = { + "middleProperty": { + "innerProperty": {"inner": {"strProperty": "hello"}}, + "prop": "original", + } + } model_dict = Outer(original_dict) # model we will access with dict syntax model_attr = Outer(original_dict) # model we will access with attr syntax @@ -2385,7 +2485,11 @@ def __init__(self, *args, **kwargs): def test_iter(): - dict_response = {"platformUpdateDomainCount": 5, "platformFaultDomainCount": 3, "virtualMachines": []} + dict_response = { + "platformUpdateDomainCount": 5, + "platformFaultDomainCount": 3, + "virtualMachines": [], + } assert isinstance(iter(dict_response), Iterable) model = BasicResource(dict_response) assert isinstance(iter(model), Iterable) @@ -2398,7 +2502,11 @@ def test_iter(): def test_len(): - dict_response = {"platformUpdateDomainCount": 5, "platformFaultDomainCount": 3, "virtualMachines": []} + dict_response = { + "platformUpdateDomainCount": 5, + "platformFaultDomainCount": 3, + "virtualMachines": [], + } model = BasicResource(dict_response) assert len(dict_response) == len(model) == 3 @@ -2552,7 +2660,11 @@ class MainModel(Model): b_prop: ModelB = rest_field(name="bProp") c_prop: ModelC = rest_field(name="cProp") - my_dict = {"aProp": {"aStrProp": "a"}, "bProp": {"bStrProp": "b"}, "cProp": {"cStrProp": "c"}} + my_dict = { + "aProp": {"aStrProp": "a"}, + "bProp": {"bStrProp": "b"}, + "cProp": {"cStrProp": "c"}, + } def _tests(my_dict: Dict[str, Any], my_model: MainModel): my_dict = copy.deepcopy(my_dict) # so we don't get rid of the dict each time we run tests @@ -2583,7 +2695,12 @@ def _tests(my_dict: Dict[str, Any], my_model: MainModel): _tests(my_dict, MainModel(my_dict)) _tests( - my_dict, MainModel(a_prop=ModelA(a_str_prop="a"), b_prop=ModelB(b_str_prop="b"), c_prop=ModelC(c_str_prop="c")) + my_dict, + MainModel( + a_prop=ModelA(a_str_prop="a"), + b_prop=ModelB(b_str_prop="b"), + c_prop=ModelC(c_str_prop="c"), + ), ) @@ -2602,7 +2719,11 @@ class MainModel(Model): b_prop: ModelB = rest_field(name="bProp") c_prop: ModelC = rest_field(name="cProp") - my_dict = {"aProp": {"aStrProp": "a"}, "bProp": {"bStrProp": "b"}, "cProp": {"cStrProp": "c"}} + my_dict = { + "aProp": {"aStrProp": "a"}, + "bProp": {"bStrProp": "b"}, + "cProp": {"cStrProp": "c"}, + } def _tests(my_dict: Dict[str, Any], my_model: MainModel): my_dict = copy.deepcopy(my_dict) # so we don't get rid of the dict each time we run tests @@ -2622,7 +2743,12 @@ def _tests(my_dict: Dict[str, Any], my_model: MainModel): _tests(my_dict, MainModel(my_dict)) _tests( - my_dict, MainModel(a_prop=ModelA(a_str_prop="a"), b_prop=ModelB(b_str_prop="b"), c_prop=ModelC(c_str_prop="c")) + my_dict, + MainModel( + a_prop=ModelA(a_str_prop="a"), + b_prop=ModelB(b_str_prop="b"), + c_prop=ModelC(c_str_prop="c"), + ), ) @@ -2641,7 +2767,11 @@ class MainModel(Model): b_prop: ModelB = rest_field(name="bProp") c_prop: ModelC = rest_field(name="cProp") - my_dict = {"aProp": {"aStrProp": "a"}, "bProp": {"bStrProp": "b"}, "cProp": {"cStrProp": "c"}} + my_dict = { + "aProp": {"aStrProp": "a"}, + "bProp": {"bStrProp": "b"}, + "cProp": {"cStrProp": "c"}, + } def _tests(my_dict: Dict[str, Any], my_model: MainModel): my_dict = copy.deepcopy(my_dict) # so we don't get rid of the dict each time we run tests @@ -2663,7 +2793,12 @@ def _tests(my_dict: Dict[str, Any], my_model: MainModel): _tests(my_dict, MainModel(my_dict)) _tests( - my_dict, MainModel(a_prop=ModelA(a_str_prop="a"), b_prop=ModelB(b_str_prop="b"), c_prop=ModelC(c_str_prop="c")) + my_dict, + MainModel( + a_prop=ModelA(a_str_prop="a"), + b_prop=ModelB(b_str_prop="b"), + c_prop=ModelC(c_str_prop="c"), + ), ) @@ -2707,7 +2842,11 @@ class MainModel(Model): b_prop: ModelB = rest_field(name="bProp") c_prop: ModelC = rest_field(name="cProp") - my_dict = {"aProp": {"aStrProp": "a"}, "bProp": {"bStrProp": "b"}, "cProp": {"cStrProp": "c"}} + my_dict = { + "aProp": {"aStrProp": "a"}, + "bProp": {"bStrProp": "b"}, + "cProp": {"cStrProp": "c"}, + } assert repr(my_dict) == repr(MainModel(my_dict)) @@ -2835,7 +2974,10 @@ def _tests(mod: ByteWrapper): assert mod["base64"] == decoded assert mod["base64url"] == decoded_urlsafe assert mod["list_base64"] == [decoded, decoded] - assert mod["map_base64url"] == {"key1": decoded_urlsafe, "key2": decoded_urlsafe} + assert mod["map_base64url"] == { + "key1": decoded_urlsafe, + "key2": decoded_urlsafe, + } _tests(mod) mod.default = byte_string @@ -2898,7 +3040,10 @@ def _tests(model: ByteArrayWrapper): assert model["base64"] == decoded assert model["base64url"] == decoded_urlsafe assert model["list_base64"] == [decoded, decoded] - assert model["map_base64url"] == {"key1": decoded_urlsafe, "key2": decoded_urlsafe} + assert model["map_base64url"] == { + "key1": decoded_urlsafe, + "key2": decoded_urlsafe, + } _tests( ByteArrayWrapper( @@ -2967,7 +3112,12 @@ def _tests(model: DatetimeWrapper): _tests( DatetimeWrapper( - default=dt, rfc3339=dt, rfc7231=dt, unix=dt, list_rfc3339=[dt, dt], dict_rfc7231={"key1": dt, "key2": dt} + default=dt, + rfc3339=dt, + rfc7231=dt, + unix=dt, + list_rfc3339=[dt, dt], + dict_rfc7231={"key1": dt, "key2": dt}, ) ) _tests( @@ -3042,26 +3192,42 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) -default_program = {"txt": "notepad", "bmp": "mspaint", "xls": "excel", "exe": "", "": None} +default_program = { + "txt": "notepad", + "bmp": "mspaint", + "xls": "excel", + "exe": "", + "": None, +} @pytest.mark.parametrize( "model", - [DictionaryWrapper({"defaultProgram": default_program}), DictionaryWrapper(default_program=default_program)], + [ + DictionaryWrapper({"defaultProgram": default_program}), + DictionaryWrapper(default_program=default_program), + ], ) def test_complex_dictionary_wrapper(model: DictionaryWrapper): assert model == {"defaultProgram": default_program} assert model.default_program == model["defaultProgram"] == default_program -@pytest.mark.parametrize("model", [DictionaryWrapper({"defaultProgram": {}}), DictionaryWrapper(default_program={})]) +@pytest.mark.parametrize( + "model", + [DictionaryWrapper({"defaultProgram": {}}), DictionaryWrapper(default_program={})], +) def test_complex_dictionary_wrapper_empty(model: DictionaryWrapper): assert model == {"defaultProgram": {}} assert model.default_program == model["defaultProgram"] == {} @pytest.mark.parametrize( - "model", [DictionaryWrapper({"defaultProgram": None}), DictionaryWrapper(default_program=None)] + "model", + [ + DictionaryWrapper({"defaultProgram": None}), + DictionaryWrapper(default_program=None), + ], ) def test_complex_dictionary_wrapper_none(model: DictionaryWrapper): assert model == {"defaultProgram": None} @@ -3085,7 +3251,13 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) -array_value = ["1, 2, 3, 4", "", None, "&S#$(*Y", "The quick brown fox jumps over the lazy dog"] +array_value = [ + "1, 2, 3, 4", + "", + None, + "&S#$(*Y", + "The quick brown fox jumps over the lazy dog", +] @pytest.mark.parametrize("model", [ArrayWrapper(array=array_value), ArrayWrapper({"array": array_value})]) @@ -3452,9 +3624,16 @@ def __init__(self, *args, **kwargs): model = CatComplex( id=2, name="Siameeee", - hates=[DogComplex(id=1, name="Potato", food="tomato"), DogComplex(id=-1, name="Tomato", food="french fries")], + hates=[ + DogComplex(id=1, name="Potato", food="tomato"), + DogComplex(id=-1, name="Tomato", food="french fries"), + ], ) - assert model.as_dict(exclude_readonly=True) == {"id": 2, "name": "Siameeee", "color": None} + assert model.as_dict(exclude_readonly=True) == { + "id": 2, + "name": "Siameeee", + "color": None, + } class Fish(Model): @@ -3640,47 +3819,81 @@ def test_body_bytes_format(): == '["dGVzdA==", "dGVzdA=="]' ) assert ( - json.dumps([bytes("test", "utf-8"), bytes("test", "utf-8")], cls=SdkJSONEncoder, format="base64") + json.dumps( + [bytes("test", "utf-8"), bytes("test", "utf-8")], + cls=SdkJSONEncoder, + format="base64", + ) == '["dGVzdA==", "dGVzdA=="]' ) assert ( - json.dumps([bytes("test", "utf-8"), bytes("test", "utf-8")], cls=SdkJSONEncoder, format="base64url") + json.dumps( + [bytes("test", "utf-8"), bytes("test", "utf-8")], + cls=SdkJSONEncoder, + format="base64url", + ) == '["dGVzdA", "dGVzdA"]' ) assert ( - json.dumps([bytearray("test", "utf-8"), bytearray("test", "utf-8")], cls=SdkJSONEncoder, format="base64") + json.dumps( + [bytearray("test", "utf-8"), bytearray("test", "utf-8")], + cls=SdkJSONEncoder, + format="base64", + ) == '["dGVzdA==", "dGVzdA=="]' ) assert ( - json.dumps([bytearray("test", "utf-8"), bytearray("test", "utf-8")], cls=SdkJSONEncoder, format="base64url") + json.dumps( + [bytearray("test", "utf-8"), bytearray("test", "utf-8")], + cls=SdkJSONEncoder, + format="base64url", + ) == '["dGVzdA", "dGVzdA"]' ) assert ( - json.dumps({"a": bytes("test", "utf-8"), "b": bytes("test", "utf-8")}, cls=SdkJSONEncoder) + json.dumps( + {"a": bytes("test", "utf-8"), "b": bytes("test", "utf-8")}, + cls=SdkJSONEncoder, + ) == '{"a": "dGVzdA==", "b": "dGVzdA=="}' ) assert ( - json.dumps({"a": bytearray("test", "utf-8"), "b": bytearray("test", "utf-8")}, cls=SdkJSONEncoder) + json.dumps( + {"a": bytearray("test", "utf-8"), "b": bytearray("test", "utf-8")}, + cls=SdkJSONEncoder, + ) == '{"a": "dGVzdA==", "b": "dGVzdA=="}' ) assert ( - json.dumps({"a": bytes("test", "utf-8"), "b": bytes("test", "utf-8")}, cls=SdkJSONEncoder, format="base64") + json.dumps( + {"a": bytes("test", "utf-8"), "b": bytes("test", "utf-8")}, + cls=SdkJSONEncoder, + format="base64", + ) == '{"a": "dGVzdA==", "b": "dGVzdA=="}' ) assert ( - json.dumps({"a": bytes("test", "utf-8"), "b": bytes("test", "utf-8")}, cls=SdkJSONEncoder, format="base64url") + json.dumps( + {"a": bytes("test", "utf-8"), "b": bytes("test", "utf-8")}, + cls=SdkJSONEncoder, + format="base64url", + ) == '{"a": "dGVzdA", "b": "dGVzdA"}' ) assert ( json.dumps( - {"a": bytearray("test", "utf-8"), "b": bytearray("test", "utf-8")}, cls=SdkJSONEncoder, format="base64" + {"a": bytearray("test", "utf-8"), "b": bytearray("test", "utf-8")}, + cls=SdkJSONEncoder, + format="base64", ) == '{"a": "dGVzdA==", "b": "dGVzdA=="}' ) assert ( json.dumps( - {"a": bytearray("test", "utf-8"), "b": bytearray("test", "utf-8")}, cls=SdkJSONEncoder, format="base64url" + {"a": bytearray("test", "utf-8"), "b": bytearray("test", "utf-8")}, + cls=SdkJSONEncoder, + format="base64url", ) == '{"a": "dGVzdA", "b": "dGVzdA"}' ) @@ -3718,7 +3931,10 @@ def test_decimal_serialization(): json.dumps([decimal.Decimal("0.33333"), decimal.Decimal("0.33333")], cls=SdkJSONEncoder) == "[0.33333, 0.33333]" ) assert ( - json.dumps({"a": decimal.Decimal("0.33333"), "b": decimal.Decimal("0.33333")}, cls=SdkJSONEncoder) + json.dumps( + {"a": decimal.Decimal("0.33333"), "b": decimal.Decimal("0.33333")}, + cls=SdkJSONEncoder, + ) == '{"a": 0.33333, "b": 0.33333}' ) @@ -3739,7 +3955,11 @@ class ModelWithEnumProperty(Model): enum_property_optional: Optional[Union[str, MyEnum]] = rest_field(name="enumPropertyOptional") enum_property_optional_none: Optional[Union[str, MyEnum]] = rest_field(name="enumPropertyOptionalNone") - raw_input = {"enumProperty": "a", "enumPropertyOptional": "b", "enumPropertyOptionalNone": None} + raw_input = { + "enumProperty": "a", + "enumPropertyOptional": "b", + "enumPropertyOptionalNone": None, + } def check_func(target: ModelWithEnumProperty): assert target.enum_property == MyEnum.A diff --git a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/aio/operations/_operations.py index c1adc7bc3de..ecba6837582 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/aio/operations/_operations.py @@ -28,16 +28,19 @@ from ..._model_base import SdkJSONEncoder, _deserialize from ...operations._operations import ( build_header_default_request, + build_header_float64_seconds_request, build_header_float_seconds_request, build_header_int32_seconds_request, build_header_iso8601_array_request, build_header_iso8601_request, build_property_default_request, + build_property_float64_seconds_request, build_property_float_seconds_array_request, build_property_float_seconds_request, build_property_int32_seconds_request, build_property_iso8601_request, build_query_default_request, + build_query_float64_seconds_request, build_query_float_seconds_request, build_query_int32_seconds_array_request, build_query_int32_seconds_request, @@ -258,6 +261,53 @@ async def float_seconds( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + async def float64_seconds( # pylint: disable=inconsistent-return-statements + self, *, input: float, **kwargs: Any + ) -> None: + """float64_seconds. + + :keyword input: Required. + :paramtype input: float + :return: None + :rtype: None + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_query_float64_seconds_request( + input=input, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client.pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + async def int32_seconds_array( # pylint: disable=inconsistent-return-statements self, *, input: List[int], **kwargs: Any ) -> None: @@ -945,6 +995,164 @@ async def float_seconds( return deserialized # type: ignore + @overload + async def float64_seconds( + self, body: _models.Float64SecondsDurationProperty, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + async def float64_seconds( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + async def float64_seconds( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + async def float64_seconds( + self, body: Union[_models.Float64SecondsDurationProperty, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Is one of the following types: Float64SecondsDurationProperty, JSON, IO[bytes] + Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty or JSON or IO[bytes] + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Float64SecondsDurationProperty] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_property_float64_seconds_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client.pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Float64SecondsDurationProperty, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload async def float_seconds_array( self, body: _models.FloatSecondsDurationArrayProperty, *, content_type: str = "application/json", **kwargs: Any @@ -1367,3 +1575,50 @@ async def float_seconds( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + + async def float64_seconds( # pylint: disable=inconsistent-return-statements + self, *, duration: float, **kwargs: Any + ) -> None: + """float64_seconds. + + :keyword duration: Required. + :paramtype duration: float + :return: None + :rtype: None + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_header_float64_seconds_request( + duration=duration, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client.pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/__init__.py b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/__init__.py index 660c3e697fe..62abe96c271 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/__init__.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from ._models import DefaultDurationProperty +from ._models import Float64SecondsDurationProperty from ._models import FloatSecondsDurationArrayProperty from ._models import FloatSecondsDurationProperty from ._models import ISO8601DurationProperty @@ -17,6 +18,7 @@ __all__ = [ "DefaultDurationProperty", + "Float64SecondsDurationProperty", "FloatSecondsDurationArrayProperty", "FloatSecondsDurationProperty", "ISO8601DurationProperty", diff --git a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/_models.py b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/_models.py index 2dcdc89031f..7b7c8af4560 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/models/_models.py @@ -44,6 +44,36 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles super().__init__(*args, **kwargs) +class Float64SecondsDurationProperty(_model_base.Model): + """Float64SecondsDurationProperty. + + All required parameters must be populated in order to send to server. + + :ivar value: Required. + :vartype value: float + """ + + value: float = rest_field() + """Required.""" + + @overload + def __init__( + self, + *, + value: float, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + class FloatSecondsDurationArrayProperty(_model_base.Model): """FloatSecondsDurationArrayProperty. diff --git a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/operations/_operations.py index cec9ea877b6..ee2692e525b 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/operations/_operations.py @@ -88,6 +88,18 @@ def build_query_float_seconds_request(*, input: float, **kwargs: Any) -> HttpReq return HttpRequest(method="GET", url=_url, params=_params, **kwargs) +def build_query_float64_seconds_request(*, input: float, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + # Construct URL + _url = "/encode/duration/query/float64-seconds" + + # Construct parameters + _params["input"] = _SERIALIZER.query("input", input, "float") + + return HttpRequest(method="GET", url=_url, params=_params, **kwargs) + + def build_query_int32_seconds_array_request(*, input: List[int], **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -168,6 +180,23 @@ def build_property_float_seconds_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) +def build_property_float64_seconds_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/encode/duration/property/float64-seconds" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + def build_property_float_seconds_array_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -245,6 +274,18 @@ def build_header_float_seconds_request(*, duration: float, **kwargs: Any) -> Htt return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) +def build_header_float64_seconds_request(*, duration: float, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + # Construct URL + _url = "/encode/duration/header/float64-seconds" + + # Construct headers + _headers["duration"] = _SERIALIZER.header("duration", duration, "float") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + class QueryOperations: """ .. warning:: @@ -446,6 +487,51 @@ def float_seconds(self, *, input: float, **kwargs: Any) -> None: # pylint: disa if cls: return cls(pipeline_response, None, {}) # type: ignore + def float64_seconds(self, *, input: float, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """float64_seconds. + + :keyword input: Required. + :paramtype input: float + :return: None + :rtype: None + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_query_float64_seconds_request( + input=input, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client.pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + def int32_seconds_array( # pylint: disable=inconsistent-return-statements self, *, input: List[int], **kwargs: Any ) -> None: @@ -1133,6 +1219,164 @@ def float_seconds( return deserialized # type: ignore + @overload + def float64_seconds( + self, body: _models.Float64SecondsDurationProperty, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + def float64_seconds( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + @overload + def float64_seconds( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + + def float64_seconds( + self, body: Union[_models.Float64SecondsDurationProperty, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Float64SecondsDurationProperty: + """float64_seconds. + + :param body: Is one of the following types: Float64SecondsDurationProperty, JSON, IO[bytes] + Required. + :type body: ~encode.duration.models.Float64SecondsDurationProperty or JSON or IO[bytes] + :return: Float64SecondsDurationProperty. The Float64SecondsDurationProperty is compatible with + MutableMapping + :rtype: ~encode.duration.models.Float64SecondsDurationProperty + :raises ~corehttp.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "value": 0.0 # Required. + } + + # response body for status code(s): 200 + response == { + "value": 0.0 # Required. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Float64SecondsDurationProperty] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_property_float64_seconds_request( + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client.pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Float64SecondsDurationProperty, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload def float_seconds_array( self, body: _models.FloatSecondsDurationArrayProperty, *, content_type: str = "application/json", **kwargs: Any @@ -1553,3 +1797,50 @@ def float_seconds( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + + def float64_seconds( # pylint: disable=inconsistent-return-statements + self, *, duration: float, **kwargs: Any + ) -> None: + """float64_seconds. + + :keyword duration: Required. + :paramtype duration: float + :return: None + :rtype: None + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_header_float64_seconds_request( + duration=duration, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client.pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/unbranded/mock_api_tests/conftest.py b/packages/typespec-python/test/unbranded/mock_api_tests/conftest.py index 0e26edd3a80..fafe7b22ce4 100644 --- a/packages/typespec-python/test/unbranded/mock_api_tests/conftest.py +++ b/packages/typespec-python/test/unbranded/mock_api_tests/conftest.py @@ -12,9 +12,7 @@ def start_server_process(): - path = Path(os.path.dirname(__file__)) / Path( - "../../../node_modules/@azure-tools/cadl-ranch-specs" - ) + path = Path(os.path.dirname(__file__)) / Path("../../../node_modules/@azure-tools/cadl-ranch-specs") os.chdir(path.resolve()) cmd = "cadl-ranch serve ./http" if os.name == "nt": @@ -26,9 +24,7 @@ def terminate_server_process(process): if os.name == "nt": process.kill() else: - os.killpg( - os.getpgid(process.pid), signal.SIGTERM - ) # Send the signal to all the process groups + os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups @pytest.fixture(scope="session", autouse=True) diff --git a/packages/typespec-python/test/unbranded/mock_api_tests/test_unbranded.py b/packages/typespec-python/test/unbranded/mock_api_tests/test_unbranded.py index 7459c0316da..01e15a26d47 100644 --- a/packages/typespec-python/test/unbranded/mock_api_tests/test_unbranded.py +++ b/packages/typespec-python/test/unbranded/mock_api_tests/test_unbranded.py @@ -54,6 +54,4 @@ def test_senstive_word(): check_folder = (Path(os.path.dirname(__file__)) / "../generated").resolve() assert [] == check_sensitive_word(check_folder, "azure") # after update cadl-ranch, it shall also equal to [] - assert ["authentication-oauth2", "authentication-union"] == check_sensitive_word( - check_folder, "microsoft" - ) + assert ["authentication-oauth2", "authentication-union"] == check_sensitive_word(check_folder, "microsoft") diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75c20a8e0da..adcf9442380 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,8 +71,8 @@ importers: specifier: ~0.13.3 version: 0.13.3(@typespec/compiler@0.55.0)(@typespec/http@0.55.0)(@typespec/rest@0.55.0)(@typespec/versioning@0.55.0) '@azure-tools/cadl-ranch-specs': - specifier: ~0.33.1 - version: 0.33.1(@azure-tools/cadl-ranch-expect@0.13.3)(@azure-tools/typespec-azure-core@0.41.0)(@typespec/compiler@0.55.0)(@typespec/http@0.55.0)(@typespec/rest@0.55.0)(@typespec/versioning@0.55.0) + specifier: ~0.33.2 + version: 0.33.2(@azure-tools/cadl-ranch-expect@0.13.3)(@azure-tools/typespec-azure-core@0.41.0)(@typespec/compiler@0.55.0)(@typespec/http@0.55.0)(@typespec/rest@0.55.0)(@typespec/versioning@0.55.0) '@azure-tools/typespec-autorest': specifier: ~0.41.0 version: 0.41.0(@azure-tools/typespec-azure-core@0.41.0)(@azure-tools/typespec-client-generator-core@0.41.8)(@typespec/compiler@0.55.0)(@typespec/http@0.55.0)(@typespec/openapi@0.55.0)(@typespec/rest@0.55.0)(@typespec/versioning@0.55.0) @@ -209,8 +209,8 @@ packages: '@typespec/versioning': 0.55.0(@typespec/compiler@0.55.0) dev: true - /@azure-tools/cadl-ranch-specs@0.33.1(@azure-tools/cadl-ranch-expect@0.13.3)(@azure-tools/typespec-azure-core@0.41.0)(@typespec/compiler@0.55.0)(@typespec/http@0.55.0)(@typespec/rest@0.55.0)(@typespec/versioning@0.55.0): - resolution: {integrity: sha512-L0e9D8coIG/MS8KRHLLaU8CnGLvxKI9HRFSntxnNXBlFT631YXzSBmZxYvPQ4T2CSfjgJhU5ETUFDKtKBH8mpw==} + /@azure-tools/cadl-ranch-specs@0.33.2(@azure-tools/cadl-ranch-expect@0.13.3)(@azure-tools/typespec-azure-core@0.41.0)(@typespec/compiler@0.55.0)(@typespec/http@0.55.0)(@typespec/rest@0.55.0)(@typespec/versioning@0.55.0): + resolution: {integrity: sha512-goFLjvXGeOC+r5oCOhI3csuWqQFPGO4iuhLdGmjyyB2YDiiNTdKXV19hyGVM2FYeHvmmgElBHdHY6E49+Z6wkw==} engines: {node: '>=16.0.0'} peerDependencies: '@azure-tools/cadl-ranch-expect': ~0.13.3