diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py index e3f4ae1da93f..2ef1ea232611 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/async_client.py @@ -28,14 +28,17 @@ ) import pkg_resources -from google.api_core.client_options import ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py index 4b380d1d73d4..da6f7754647c 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/client.py @@ -14,23 +14,25 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Iterable, Iterator, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -268,8 +270,15 @@ def __init__( client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( + "true", + "false", + ): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + use_client_cert = ( + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" ) client_cert_source_func = None diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/base.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/base.py index cc80dec6f2f0..0c56180cbc4c 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/base.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/base.py @@ -18,11 +18,11 @@ import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py index c3c6aa43f6df..f788b693ccd5 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc.py @@ -16,9 +16,9 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py index 68e2e27e4ba8..6069826dbc11 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py @@ -16,9 +16,9 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1/types/cloud_speech.py b/packages/google-cloud-speech/google/cloud/speech_v1/types/cloud_speech.py index 408b9e1c2d22..e5b382f9b4c8 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1/types/cloud_speech.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1/types/cloud_speech.py @@ -98,6 +98,7 @@ class TranscriptOutputConfig(proto.Message): Must be specified in the format: ``gs://bucket_name/object_name``, and the bucket must already exist. + This field is a member of `oneof`_ ``output_type``. """ @@ -125,6 +126,7 @@ class StreamingRecognizeRequest(proto.Message): Provides information to the recognizer that specifies how to process the request. The first ``StreamingRecognizeRequest`` message must contain a ``streaming_config`` message. + This field is a member of `oneof`_ ``streaming_request``. audio_content (bytes): The audio data to be recognized. Sequential chunks of audio @@ -137,6 +139,7 @@ class StreamingRecognizeRequest(proto.Message): fields, proto buffers use a pure binary representation (not base64). See `content limits `__. + This field is a member of `oneof`_ ``streaming_request``. """ @@ -557,6 +560,7 @@ class RecognitionAudio(proto.Message): ``RecognitionConfig``. Note: as with all bytes fields, proto buffers use a pure binary representation, whereas JSON representations use base64. + This field is a member of `oneof`_ ``audio_source``. uri (str): URI that points to a file that contains audio data bytes as @@ -568,6 +572,7 @@ class RecognitionAudio(proto.Message): [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see `Request URIs `__. + This field is a member of `oneof`_ ``audio_source``. """ diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py index e6a9f829c972..3a97c5c72e4e 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py @@ -19,14 +19,17 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core.client_options import ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.speech_v1p1beta1.services.adaptation import pagers from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py index 7d01c840bdd1..409f57203ada 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/client.py @@ -14,23 +14,25 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.speech_v1p1beta1.services.adaptation import pagers from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation @@ -299,8 +301,15 @@ def __init__( client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( + "true", + "false", + ): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + use_client_cert = ( + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" ) client_cert_source_func = None diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/base.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/base.py index 69be021d2a4c..1e89db8b2740 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/base.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/base.py @@ -18,10 +18,10 @@ import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py index 0c2535f23d4f..081655d16b17 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py @@ -16,8 +16,8 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py index b929c3eed4f2..5bb1c88f829f 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py @@ -16,8 +16,8 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py index 4b74e25940d0..cd9314990cb0 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/async_client.py @@ -28,14 +28,17 @@ ) import pkg_resources -from google.api_core.client_options import ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py index 60503d005260..8d973cb57c68 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/client.py @@ -14,23 +14,25 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Iterable, Iterator, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -300,8 +302,15 @@ def __init__( client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( + "true", + "false", + ): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + use_client_cert = ( + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" ) client_cert_source_func = None diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/base.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/base.py index 60030be81af9..3904e18c6113 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/base.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/base.py @@ -18,11 +18,11 @@ import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py index 28c0f5401c07..1a5ffc825542 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py @@ -16,9 +16,9 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py index aeac245829e4..666eff0ce0a4 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py @@ -16,9 +16,9 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/types/cloud_speech.py b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/types/cloud_speech.py index c913e147c82b..4a35977babcf 100644 --- a/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/types/cloud_speech.py +++ b/packages/google-cloud-speech/google/cloud/speech_v1p1beta1/types/cloud_speech.py @@ -100,6 +100,7 @@ class TranscriptOutputConfig(proto.Message): Must be specified in the format: ``gs://bucket_name/object_name``, and the bucket must already exist. + This field is a member of `oneof`_ ``output_type``. """ @@ -127,6 +128,7 @@ class StreamingRecognizeRequest(proto.Message): Provides information to the recognizer that specifies how to process the request. The first ``StreamingRecognizeRequest`` message must contain a ``streaming_config`` message. + This field is a member of `oneof`_ ``streaming_request``. audio_content (bytes): The audio data to be recognized. Sequential chunks of audio @@ -139,6 +141,7 @@ class StreamingRecognizeRequest(proto.Message): fields, proto buffers use a pure binary representation (not base64). See `content limits `__. + This field is a member of `oneof`_ ``streaming_request``. """ @@ -654,6 +657,7 @@ class RecognitionAudio(proto.Message): ``RecognitionConfig``. Note: as with all bytes fields, proto buffers use a pure binary representation, whereas JSON representations use base64. + This field is a member of `oneof`_ ``audio_source``. uri (str): URI that points to a file that contains audio data bytes as @@ -665,6 +669,7 @@ class RecognitionAudio(proto.Message): [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see `Request URIs `__. + This field is a member of `oneof`_ ``audio_source``. """ diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py index e9a78bb6ce3b..6d6e0c1fd77b 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v1/test_speech.py @@ -543,10 +543,14 @@ def test_recognize_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val def test_recognize_flattened_error(): @@ -589,10 +593,14 @@ async def test_recognize_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val @pytest.mark.asyncio @@ -719,10 +727,14 @@ def test_long_running_recognize_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val def test_long_running_recognize_flattened_error(): @@ -767,10 +779,14 @@ async def test_long_running_recognize_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val @pytest.mark.asyncio diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py index 9e1b9a6f325f..7f235622f3c2 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_adaptation.py @@ -630,9 +630,15 @@ def test_create_phrase_set_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].phrase_set == resource.PhraseSet(name="name_value") - assert args[0].phrase_set_id == "phrase_set_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].phrase_set + mock_val = resource.PhraseSet(name="name_value") + assert arg == mock_val + arg = args[0].phrase_set_id + mock_val = "phrase_set_id_value" + assert arg == mock_val def test_create_phrase_set_flattened_error(): @@ -673,9 +679,15 @@ async def test_create_phrase_set_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].phrase_set == resource.PhraseSet(name="name_value") - assert args[0].phrase_set_id == "phrase_set_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].phrase_set + mock_val = resource.PhraseSet(name="name_value") + assert arg == mock_val + arg = args[0].phrase_set_id + mock_val = "phrase_set_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -841,7 +853,9 @@ def test_get_phrase_set_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_phrase_set_flattened_error(): @@ -873,7 +887,9 @@ async def test_get_phrase_set_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1040,7 +1056,9 @@ def test_list_phrase_set_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_phrase_set_flattened_error(): @@ -1074,7 +1092,9 @@ async def test_list_phrase_set_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1402,8 +1422,12 @@ def test_update_phrase_set_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].phrase_set == resource.PhraseSet(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].phrase_set + mock_val = resource.PhraseSet(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_phrase_set_flattened_error(): @@ -1442,8 +1466,12 @@ async def test_update_phrase_set_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].phrase_set == resource.PhraseSet(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].phrase_set + mock_val = resource.PhraseSet(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio @@ -1614,7 +1642,9 @@ def test_delete_phrase_set_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_phrase_set_flattened_error(): @@ -1648,7 +1678,9 @@ async def test_delete_phrase_set_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1834,9 +1866,15 @@ def test_create_custom_class_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].custom_class == resource.CustomClass(name="name_value") - assert args[0].custom_class_id == "custom_class_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].custom_class + mock_val = resource.CustomClass(name="name_value") + assert arg == mock_val + arg = args[0].custom_class_id + mock_val = "custom_class_id_value" + assert arg == mock_val def test_create_custom_class_flattened_error(): @@ -1879,9 +1917,15 @@ async def test_create_custom_class_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].custom_class == resource.CustomClass(name="name_value") - assert args[0].custom_class_id == "custom_class_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].custom_class + mock_val = resource.CustomClass(name="name_value") + assert arg == mock_val + arg = args[0].custom_class_id + mock_val = "custom_class_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2053,7 +2097,9 @@ def test_get_custom_class_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_custom_class_flattened_error(): @@ -2087,7 +2133,9 @@ async def test_get_custom_class_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2267,7 +2315,9 @@ def test_list_custom_classes_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_custom_classes_flattened_error(): @@ -2303,7 +2353,9 @@ async def test_list_custom_classes_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2648,8 +2700,12 @@ def test_update_custom_class_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].custom_class == resource.CustomClass(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].custom_class + mock_val = resource.CustomClass(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_custom_class_flattened_error(): @@ -2690,8 +2746,12 @@ async def test_update_custom_class_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].custom_class == resource.CustomClass(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].custom_class + mock_val = resource.CustomClass(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio @@ -2863,7 +2923,9 @@ def test_delete_custom_class_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_custom_class_flattened_error(): @@ -2897,7 +2959,9 @@ async def test_delete_custom_class_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio diff --git a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py index 86cb799a4131..0e1dac3486fa 100644 --- a/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py +++ b/packages/google-cloud-speech/tests/unit/gapic/speech_v1p1beta1/test_speech.py @@ -545,10 +545,14 @@ def test_recognize_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val def test_recognize_flattened_error(): @@ -591,10 +595,14 @@ async def test_recognize_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val @pytest.mark.asyncio @@ -721,10 +729,14 @@ def test_long_running_recognize_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val def test_long_running_recognize_flattened_error(): @@ -769,10 +781,14 @@ async def test_long_running_recognize_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].config == cloud_speech.RecognitionConfig( + arg = args[0].config + mock_val = cloud_speech.RecognitionConfig( encoding=cloud_speech.RecognitionConfig.AudioEncoding.LINEAR16 ) - assert args[0].audio == cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val + arg = args[0].audio + mock_val = cloud_speech.RecognitionAudio(content=b"content_blob") + assert arg == mock_val @pytest.mark.asyncio