From b8e16f8a17a49c1fc65f7f4392e33fb273bcd8ca Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 5 Nov 2021 15:14:13 +0000 Subject: [PATCH] feat(v3beta1): added support for comparing between versions (#202) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 407624272 Source-Link: https://github.com/googleapis/googleapis/commit/eb773f2c089d7f11efbf6f72239db6c16189927a Source-Link: https://github.com/googleapis/googleapis-gen/commit/e69f86b5bbc2ed777a5d97b65c080c4645ea02b8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTY5Zjg2YjViYmMyZWQ3NzdhNWQ5N2I2NWMwODBjNDY0NWVhMDJiOCJ9 docs(v3beta1): clarified security settings API reference --- google/cloud/dialogflowcx_v3beta1/__init__.py | 4 + .../dialogflowcx_v3beta1/gapic_metadata.json | 10 + .../services/versions/async_client.py | 78 +++++++ .../services/versions/client.py | 78 +++++++ .../services/versions/transports/base.py | 14 ++ .../services/versions/transports/grpc.py | 27 +++ .../versions/transports/grpc_asyncio.py | 29 +++ .../dialogflowcx_v3beta1/types/__init__.py | 4 + .../types/security_settings.py | 15 +- .../dialogflowcx_v3beta1/types/version.py | 56 +++++ .../dialogflowcx_v3beta1/test_versions.py | 209 ++++++++++++++++++ 11 files changed, 522 insertions(+), 2 deletions(-) diff --git a/google/cloud/dialogflowcx_v3beta1/__init__.py b/google/cloud/dialogflowcx_v3beta1/__init__.py index d3b5023c..e2126f7a 100644 --- a/google/cloud/dialogflowcx_v3beta1/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/__init__.py @@ -229,6 +229,8 @@ from .types.transition_route_group import UpdateTransitionRouteGroupRequest from .types.validation_message import ResourceName from .types.validation_message import ValidationMessage +from .types.version import CompareVersionsRequest +from .types.version import CompareVersionsResponse from .types.version import CreateVersionOperationMetadata from .types.version import CreateVersionRequest from .types.version import DeleteVersionRequest @@ -281,6 +283,8 @@ "CalculateCoverageResponse", "Changelog", "ChangelogsClient", + "CompareVersionsRequest", + "CompareVersionsResponse", "ContinuousTestResult", "ConversationTurn", "CreateAgentRequest", diff --git a/google/cloud/dialogflowcx_v3beta1/gapic_metadata.json b/google/cloud/dialogflowcx_v3beta1/gapic_metadata.json index 971d5bf0..a59ccd58 100644 --- a/google/cloud/dialogflowcx_v3beta1/gapic_metadata.json +++ b/google/cloud/dialogflowcx_v3beta1/gapic_metadata.json @@ -1056,6 +1056,11 @@ "grpc": { "libraryClient": "VersionsClient", "rpcs": { + "CompareVersions": { + "methods": [ + "compare_versions" + ] + }, "CreateVersion": { "methods": [ "create_version" @@ -1091,6 +1096,11 @@ "grpc-async": { "libraryClient": "VersionsAsyncClient", "rpcs": { + "CompareVersions": { + "methods": [ + "compare_versions" + ] + }, "CreateVersion": { "methods": [ "create_version" diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py index 1d88a21a..63b0d4b3 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py @@ -678,6 +678,84 @@ async def load_version( # Done; return the response. return response + async def compare_versions( + self, + request: Union[version.CompareVersionsRequest, dict] = None, + *, + base_version: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> version.CompareVersionsResponse: + r"""Compares the specified base version with target + version. + + Args: + request (Union[google.cloud.dialogflowcx_v3beta1.types.CompareVersionsRequest, dict]): + The request object. The request message for + [Versions.CompareVersions][google.cloud.dialogflow.cx.v3beta1.Versions.CompareVersions]. + base_version (:class:`str`): + Required. Name of the base flow version to compare with + the target version. Use version ID ``0`` to indicate the + draft version of the specified flow. + + Format: + ``projects//locations//agents/ /flows//versions/``. + + This corresponds to the ``base_version`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.dialogflowcx_v3beta1.types.CompareVersionsResponse: + The response message for + [Versions.CompareVersions][google.cloud.dialogflow.cx.v3beta1.Versions.CompareVersions]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([base_version]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = version.CompareVersionsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if base_version is not None: + request.base_version = base_version + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.compare_versions, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("base_version", request.base_version),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/client.py b/google/cloud/dialogflowcx_v3beta1/services/versions/client.py index 0999ab8b..57361ac8 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/client.py @@ -872,6 +872,84 @@ def load_version( # Done; return the response. return response + def compare_versions( + self, + request: Union[version.CompareVersionsRequest, dict] = None, + *, + base_version: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> version.CompareVersionsResponse: + r"""Compares the specified base version with target + version. + + Args: + request (Union[google.cloud.dialogflowcx_v3beta1.types.CompareVersionsRequest, dict]): + The request object. The request message for + [Versions.CompareVersions][google.cloud.dialogflow.cx.v3beta1.Versions.CompareVersions]. + base_version (str): + Required. Name of the base flow version to compare with + the target version. Use version ID ``0`` to indicate the + draft version of the specified flow. + + Format: + ``projects//locations//agents/ /flows//versions/``. + + This corresponds to the ``base_version`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.dialogflowcx_v3beta1.types.CompareVersionsResponse: + The response message for + [Versions.CompareVersions][google.cloud.dialogflow.cx.v3beta1.Versions.CompareVersions]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([base_version]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a version.CompareVersionsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, version.CompareVersionsRequest): + request = version.CompareVersionsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if base_version is not None: + request.base_version = base_version + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.compare_versions] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("base_version", request.base_version),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + def __enter__(self): return self diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py index 293c4ea2..96dc75e2 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py @@ -146,6 +146,9 @@ def _prep_wrapped_messages(self, client_info): self.load_version: gapic_v1.method.wrap_method( self.load_version, default_timeout=None, client_info=client_info, ), + self.compare_versions: gapic_v1.method.wrap_method( + self.compare_versions, default_timeout=None, client_info=client_info, + ), } def close(self): @@ -215,5 +218,16 @@ def load_version( ]: raise NotImplementedError() + @property + def compare_versions( + self, + ) -> Callable[ + [version.CompareVersionsRequest], + Union[ + version.CompareVersionsResponse, Awaitable[version.CompareVersionsResponse] + ], + ]: + raise NotImplementedError() + __all__ = ("VersionsTransport",) diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py index 119fa29f..230e8c0b 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py @@ -425,6 +425,33 @@ def load_version( ) return self._stubs["load_version"] + @property + def compare_versions( + self, + ) -> Callable[[version.CompareVersionsRequest], version.CompareVersionsResponse]: + r"""Return a callable for the compare versions method over gRPC. + + Compares the specified base version with target + version. + + Returns: + Callable[[~.CompareVersionsRequest], + ~.CompareVersionsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "compare_versions" not in self._stubs: + self._stubs["compare_versions"] = self.grpc_channel.unary_unary( + "/google.cloud.dialogflow.cx.v3beta1.Versions/CompareVersions", + request_serializer=version.CompareVersionsRequest.serialize, + response_deserializer=version.CompareVersionsResponse.deserialize, + ) + return self._stubs["compare_versions"] + def close(self): self.grpc_channel.close() diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py index e21ee3c1..a1d04a3b 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py @@ -435,6 +435,35 @@ def load_version( ) return self._stubs["load_version"] + @property + def compare_versions( + self, + ) -> Callable[ + [version.CompareVersionsRequest], Awaitable[version.CompareVersionsResponse] + ]: + r"""Return a callable for the compare versions method over gRPC. + + Compares the specified base version with target + version. + + Returns: + Callable[[~.CompareVersionsRequest], + Awaitable[~.CompareVersionsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "compare_versions" not in self._stubs: + self._stubs["compare_versions"] = self.grpc_channel.unary_unary( + "/google.cloud.dialogflow.cx.v3beta1.Versions/CompareVersions", + request_serializer=version.CompareVersionsRequest.serialize, + response_deserializer=version.CompareVersionsResponse.deserialize, + ) + return self._stubs["compare_versions"] + def close(self): return self.grpc_channel.close() diff --git a/google/cloud/dialogflowcx_v3beta1/types/__init__.py b/google/cloud/dialogflowcx_v3beta1/types/__init__.py index 81aaa5cd..50d69e71 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/types/__init__.py @@ -228,6 +228,8 @@ ValidationMessage, ) from .version import ( + CompareVersionsRequest, + CompareVersionsResponse, CreateVersionOperationMetadata, CreateVersionRequest, DeleteVersionRequest, @@ -435,6 +437,8 @@ "UpdateTransitionRouteGroupRequest", "ResourceName", "ValidationMessage", + "CompareVersionsRequest", + "CompareVersionsResponse", "CreateVersionOperationMetadata", "CreateVersionRequest", "DeleteVersionRequest", diff --git a/google/cloud/dialogflowcx_v3beta1/types/security_settings.py b/google/cloud/dialogflowcx_v3beta1/types/security_settings.py index 6e2b1a02..1d00315c 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/security_settings.py +++ b/google/cloud/dialogflowcx_v3beta1/types/security_settings.py @@ -173,6 +173,11 @@ class SecuritySettings(proto.Message): `DLP `__ inspect template name. Use this template to define inspect base settings. + The ``DLP Inspect Templates Reader`` role is needed on the + Dialogflow service identity service account (has the form + ``service-PROJECT_NUMBER@gcp-sa-dialogflow.iam.gserviceaccount.com``) + for your agent's project. + If empty, we use the default DLP inspect config. The template name will have one of the following formats: @@ -187,6 +192,12 @@ class SecuritySettings(proto.Message): template name. Use this template to define de-identification configuration for the content. + The ``DLP De-identify Templates Reader`` role is needed on + the Dialogflow service identity service account (has the + form + ``service-PROJECT_NUMBER@gcp-sa-dialogflow.iam.gserviceaccount.com``) + for your agent's project. + If empty, Dialogflow replaces sensitive info with ``[redacted]`` text. @@ -202,8 +213,8 @@ class SecuritySettings(proto.Message): specified number of days. This does not apply to Cloud logging, which is owned by the user - not Dialogflow. - User must Set a value lower than Dialogflow's - default 30d TTL. Setting a value higher than + User must set a value lower than Dialogflow's + default 365d TTL. Setting a value higher than that has no effect. A missing value or setting to 0 also means we use Dialogflow's default TTL. diff --git a/google/cloud/dialogflowcx_v3beta1/types/version.py b/google/cloud/dialogflowcx_v3beta1/types/version.py index f5e3de5e..27b474cb 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/version.py +++ b/google/cloud/dialogflowcx_v3beta1/types/version.py @@ -32,6 +32,8 @@ "UpdateVersionRequest", "DeleteVersionRequest", "LoadVersionRequest", + "CompareVersionsRequest", + "CompareVersionsResponse", }, ) @@ -229,4 +231,58 @@ class LoadVersionRequest(proto.Message): allow_override_agent_resources = proto.Field(proto.BOOL, number=2,) +class CompareVersionsRequest(proto.Message): + r"""The request message for + [Versions.CompareVersions][google.cloud.dialogflow.cx.v3beta1.Versions.CompareVersions]. + + Attributes: + base_version (str): + Required. Name of the base flow version to compare with the + target version. Use version ID ``0`` to indicate the draft + version of the specified flow. + + Format: + ``projects//locations//agents/ /flows//versions/``. + target_version (str): + Required. Name of the target flow version to compare with + the base version. Use version ID ``0`` to indicate the draft + version of the specified flow. Format: + ``projects//locations//agents//flows//versions/``. + language_code (str): + The language to compare the flow versions for. + + If not specified, the agent's default language is used. + `Many + languages `__ + are supported. Note: languages must be enabled in the agent + before they can be used. + """ + + base_version = proto.Field(proto.STRING, number=1,) + target_version = proto.Field(proto.STRING, number=2,) + language_code = proto.Field(proto.STRING, number=3,) + + +class CompareVersionsResponse(proto.Message): + r"""The response message for + [Versions.CompareVersions][google.cloud.dialogflow.cx.v3beta1.Versions.CompareVersions]. + + Attributes: + base_version_content_json (str): + JSON representation of the base version + content. + target_version_content_json (str): + JSON representation of the target version + content. + compare_time (google.protobuf.timestamp_pb2.Timestamp): + The timestamp when the two version compares. + """ + + base_version_content_json = proto.Field(proto.STRING, number=1,) + target_version_content_json = proto.Field(proto.STRING, number=2,) + compare_time = proto.Field( + proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py index e7cea71d..679b1e7e 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py @@ -1795,6 +1795,214 @@ async def test_load_version_flattened_error_async(): ) +def test_compare_versions( + transport: str = "grpc", request_type=version.CompareVersionsRequest +): + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.compare_versions), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = version.CompareVersionsResponse( + base_version_content_json="base_version_content_json_value", + target_version_content_json="target_version_content_json_value", + ) + response = client.compare_versions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == version.CompareVersionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, version.CompareVersionsResponse) + assert response.base_version_content_json == "base_version_content_json_value" + assert response.target_version_content_json == "target_version_content_json_value" + + +def test_compare_versions_from_dict(): + test_compare_versions(request_type=dict) + + +def test_compare_versions_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.compare_versions), "__call__") as call: + client.compare_versions() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == version.CompareVersionsRequest() + + +@pytest.mark.asyncio +async def test_compare_versions_async( + transport: str = "grpc_asyncio", request_type=version.CompareVersionsRequest +): + client = VersionsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.compare_versions), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + version.CompareVersionsResponse( + base_version_content_json="base_version_content_json_value", + target_version_content_json="target_version_content_json_value", + ) + ) + response = await client.compare_versions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == version.CompareVersionsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, version.CompareVersionsResponse) + assert response.base_version_content_json == "base_version_content_json_value" + assert response.target_version_content_json == "target_version_content_json_value" + + +@pytest.mark.asyncio +async def test_compare_versions_async_from_dict(): + await test_compare_versions_async(request_type=dict) + + +def test_compare_versions_field_headers(): + client = VersionsClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = version.CompareVersionsRequest() + + request.base_version = "base_version/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.compare_versions), "__call__") as call: + call.return_value = version.CompareVersionsResponse() + client.compare_versions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "base_version=base_version/value",) in kw[ + "metadata" + ] + + +@pytest.mark.asyncio +async def test_compare_versions_field_headers_async(): + client = VersionsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = version.CompareVersionsRequest() + + request.base_version = "base_version/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.compare_versions), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + version.CompareVersionsResponse() + ) + await client.compare_versions(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "base_version=base_version/value",) in kw[ + "metadata" + ] + + +def test_compare_versions_flattened(): + client = VersionsClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.compare_versions), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = version.CompareVersionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.compare_versions(base_version="base_version_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].base_version == "base_version_value" + + +def test_compare_versions_flattened_error(): + client = VersionsClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.compare_versions( + version.CompareVersionsRequest(), base_version="base_version_value", + ) + + +@pytest.mark.asyncio +async def test_compare_versions_flattened_async(): + client = VersionsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.compare_versions), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = version.CompareVersionsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + version.CompareVersionsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.compare_versions(base_version="base_version_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].base_version == "base_version_value" + + +@pytest.mark.asyncio +async def test_compare_versions_flattened_error_async(): + client = VersionsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.compare_versions( + version.CompareVersionsRequest(), base_version="base_version_value", + ) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.VersionsGrpcTransport( @@ -1895,6 +2103,7 @@ def test_versions_base_transport(): "update_version", "delete_version", "load_version", + "compare_versions", ) for method in methods: with pytest.raises(NotImplementedError):