From 2a214b56bb0bb33acdad601619d4bd1f803fd44a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 5 Nov 2021 18:28:27 +0100 Subject: [PATCH 01/26] chore(deps): update all dependencies (#293) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update all dependencies * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- samples/snippets/hybrid_glossaries/requirements.txt | 2 +- samples/snippets/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/snippets/hybrid_glossaries/requirements.txt b/samples/snippets/hybrid_glossaries/requirements.txt index 5acda81c..cb755cb2 100644 --- a/samples/snippets/hybrid_glossaries/requirements.txt +++ b/samples/snippets/hybrid_glossaries/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-translate==3.6.0 +google-cloud-translate==3.6.1 google-cloud-vision==2.6.2 google-cloud-texttospeech==2.7.1 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 79a02771..fa4d8cab 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-translate==3.6.0 +google-cloud-translate==3.6.1 google-cloud-storage==1.42.3 google-cloud-automl==2.5.2 From 0ae9c88ef4d87e2b3f6bea085aa06984749bab91 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 9 Nov 2021 15:30:57 -0500 Subject: [PATCH 02/26] chore: use gapic-generator-python 0.56.2 (#296) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update Java and Python dependencies PiperOrigin-RevId: 408420890 Source-Link: https://github.com/googleapis/googleapis/commit/2921f9fb3bfbd16f6b2da0104373e2b47a80a65e Source-Link: https://github.com/googleapis/googleapis-gen/commit/6598ca8cbbf5226733a099c4506518a5af6ff74c Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjU5OGNhOGNiYmY1MjI2NzMzYTA5OWM0NTA2NTE4YTVhZjZmZjc0YyJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../translation_service/async_client.py | 13 +- .../services/translation_service/client.py | 25 ++- .../translation_service/transports/base.py | 10 +- .../translation_service/transports/grpc.py | 6 +- .../transports/grpc_asyncio.py | 6 +- .../translate_v3/types/translation_service.py | 2 + .../translation_service/async_client.py | 13 +- .../services/translation_service/client.py | 25 ++- .../translation_service/transports/base.py | 10 +- .../translation_service/transports/grpc.py | 6 +- .../transports/grpc_asyncio.py | 6 +- .../types/translation_service.py | 2 + .../translate_v3/test_translation_service.py | 176 +++++++++++++----- .../test_translation_service.py | 136 ++++++++++---- 14 files changed, 310 insertions(+), 126 deletions(-) diff --git a/google/cloud/translate_v3/services/translation_service/async_client.py b/google/cloud/translate_v3/services/translation_service/async_client.py index 834a7e34..a9ef6b4c 100644 --- a/google/cloud/translate_v3/services/translation_service/async_client.py +++ b/google/cloud/translate_v3/services/translation_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore diff --git a/google/cloud/translate_v3/services/translation_service/client.py b/google/cloud/translate_v3/services/translation_service/client.py index 625b4ea0..22667161 100644 --- a/google/cloud/translate_v3/services/translation_service/client.py +++ b/google/cloud/translate_v3/services/translation_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -288,8 +290,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/google/cloud/translate_v3/services/translation_service/transports/base.py b/google/cloud/translate_v3/services/translation_service/transports/base.py index 759772df..02d30a4b 100644 --- a/google/cloud/translate_v3/services/translation_service/transports/base.py +++ b/google/cloud/translate_v3/services/translation_service/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/google/cloud/translate_v3/services/translation_service/transports/grpc.py b/google/cloud/translate_v3/services/translation_service/transports/grpc.py index 15d9988f..e608b61f 100644 --- a/google/cloud/translate_v3/services/translation_service/transports/grpc.py +++ b/google/cloud/translate_v3/services/translation_service/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/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py b/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py index 5f418f68..68c4840b 100644 --- a/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py +++ b/google/cloud/translate_v3/services/translation_service/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/google/cloud/translate_v3/types/translation_service.py b/google/cloud/translate_v3/types/translation_service.py index 4e97c94f..66c24dce 100644 --- a/google/cloud/translate_v3/types/translation_service.py +++ b/google/cloud/translate_v3/types/translation_service.py @@ -565,6 +565,7 @@ class OutputConfig(proto.Message): glossary_error_file will be generated that contains error details. glossary_error_file has format of gs://translation_test/a_b_c\_'trg'_glossary_errors.[extension] + This field is a member of `oneof`_ ``destination``. """ @@ -592,6 +593,7 @@ class DocumentInputConfig(proto.Message): gcs_source (google.cloud.translate_v3.types.GcsSource): Google Cloud Storage location. This must be a single file. For example: gs://example_bucket/example_file.pdf + This field is a member of `oneof`_ ``source``. mime_type (str): Specifies the input document's mime_type. diff --git a/google/cloud/translate_v3beta1/services/translation_service/async_client.py b/google/cloud/translate_v3beta1/services/translation_service/async_client.py index dcd1cc69..275d0de0 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/async_client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore diff --git a/google/cloud/translate_v3beta1/services/translation_service/client.py b/google/cloud/translate_v3beta1/services/translation_service/client.py index fd17473e..1df2ed28 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -288,8 +290,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/google/cloud/translate_v3beta1/services/translation_service/transports/base.py b/google/cloud/translate_v3beta1/services/translation_service/transports/base.py index 60c51f39..1599f819 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/transports/base.py +++ b/google/cloud/translate_v3beta1/services/translation_service/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/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py b/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py index f1c5b4bf..89303173 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py +++ b/google/cloud/translate_v3beta1/services/translation_service/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/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py b/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py index b5b4feb9..a17b04da 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py +++ b/google/cloud/translate_v3beta1/services/translation_service/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/google/cloud/translate_v3beta1/types/translation_service.py b/google/cloud/translate_v3beta1/types/translation_service.py index 272b82a6..f894223a 100644 --- a/google/cloud/translate_v3beta1/types/translation_service.py +++ b/google/cloud/translate_v3beta1/types/translation_service.py @@ -556,6 +556,7 @@ class OutputConfig(proto.Message): glossary_error_file will be generated that contains error details. glossary_error_file has format of gs://translation_test/a_b_c\_'trg'_glossary_errors.[extension] + This field is a member of `oneof`_ ``destination``. """ @@ -583,6 +584,7 @@ class DocumentInputConfig(proto.Message): gcs_source (google.cloud.translate_v3beta1.types.GcsSource): Google Cloud Storage location. This must be a single file. For example: gs://example_bucket/example_file.pdf + This field is a member of `oneof`_ ``source``. mime_type (str): Specifies the input document's mime_type. diff --git a/tests/unit/gapic/translate_v3/test_translation_service.py b/tests/unit/gapic/translate_v3/test_translation_service.py index 0130b68c..7be7d10b 100644 --- a/tests/unit/gapic/translate_v3/test_translation_service.py +++ b/tests/unit/gapic/translate_v3/test_translation_service.py @@ -656,12 +656,24 @@ def test_translate_text_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].target_language_code == "target_language_code_value" - assert args[0].contents == ["contents_value"] - assert args[0].model == "model_value" - assert args[0].mime_type == "mime_type_value" - assert args[0].source_language_code == "source_language_code_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].target_language_code + mock_val = "target_language_code_value" + assert arg == mock_val + arg = args[0].contents + mock_val = ["contents_value"] + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].mime_type + mock_val = "mime_type_value" + assert arg == mock_val + arg = args[0].source_language_code + mock_val = "source_language_code_value" + assert arg == mock_val def test_translate_text_flattened_error(): @@ -712,12 +724,24 @@ async def test_translate_text_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].target_language_code == "target_language_code_value" - assert args[0].contents == ["contents_value"] - assert args[0].model == "model_value" - assert args[0].mime_type == "mime_type_value" - assert args[0].source_language_code == "source_language_code_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].target_language_code + mock_val = "target_language_code_value" + assert arg == mock_val + arg = args[0].contents + mock_val = ["contents_value"] + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].mime_type + mock_val = "mime_type_value" + assert arg == mock_val + arg = args[0].source_language_code + mock_val = "source_language_code_value" + assert arg == mock_val @pytest.mark.asyncio @@ -897,9 +921,15 @@ def test_detect_language_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == "model_value" - assert args[0].mime_type == "mime_type_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].mime_type + mock_val = "mime_type_value" + assert arg == mock_val assert args[0].content == "content_value" @@ -947,9 +977,15 @@ async def test_detect_language_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == "model_value" - assert args[0].mime_type == "mime_type_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].mime_type + mock_val = "mime_type_value" + assert arg == mock_val assert args[0].content == "content_value" @@ -1140,9 +1176,15 @@ def test_get_supported_languages_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == "model_value" - assert args[0].display_language_code == "display_language_code_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].display_language_code + mock_val = "display_language_code_value" + assert arg == mock_val def test_get_supported_languages_flattened_error(): @@ -1189,9 +1231,15 @@ async def test_get_supported_languages_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == "model_value" - assert args[0].display_language_code == "display_language_code_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].display_language_code + mock_val = "display_language_code_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1686,19 +1734,29 @@ def test_batch_translate_document_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].source_language_code == "source_language_code_value" - assert args[0].target_language_codes == ["target_language_codes_value"] - assert args[0].input_configs == [ + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].source_language_code + mock_val = "source_language_code_value" + assert arg == mock_val + arg = args[0].target_language_codes + mock_val = ["target_language_codes_value"] + assert arg == mock_val + arg = args[0].input_configs + mock_val = [ translation_service.BatchDocumentInputConfig( gcs_source=translation_service.GcsSource(input_uri="input_uri_value") ) ] - assert args[0].output_config == translation_service.BatchDocumentOutputConfig( + assert arg == mock_val + arg = args[0].output_config + mock_val = translation_service.BatchDocumentOutputConfig( gcs_destination=translation_service.GcsDestination( output_uri_prefix="output_uri_prefix_value" ) ) + assert arg == mock_val def test_batch_translate_document_flattened_error(): @@ -1769,19 +1827,29 @@ async def test_batch_translate_document_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].source_language_code == "source_language_code_value" - assert args[0].target_language_codes == ["target_language_codes_value"] - assert args[0].input_configs == [ + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].source_language_code + mock_val = "source_language_code_value" + assert arg == mock_val + arg = args[0].target_language_codes + mock_val = ["target_language_codes_value"] + assert arg == mock_val + arg = args[0].input_configs + mock_val = [ translation_service.BatchDocumentInputConfig( gcs_source=translation_service.GcsSource(input_uri="input_uri_value") ) ] - assert args[0].output_config == translation_service.BatchDocumentOutputConfig( + assert arg == mock_val + arg = args[0].output_config + mock_val = translation_service.BatchDocumentOutputConfig( gcs_destination=translation_service.GcsDestination( output_uri_prefix="output_uri_prefix_value" ) ) + assert arg == mock_val @pytest.mark.asyncio @@ -1968,8 +2036,12 @@ def test_create_glossary_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].glossary == translation_service.Glossary(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].glossary + mock_val = translation_service.Glossary(name="name_value") + assert arg == mock_val def test_create_glossary_flattened_error(): @@ -2012,8 +2084,12 @@ async def test_create_glossary_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].glossary == translation_service.Glossary(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].glossary + mock_val = translation_service.Glossary(name="name_value") + assert arg == mock_val @pytest.mark.asyncio @@ -2190,7 +2266,9 @@ def test_list_glossaries_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_glossaries_flattened_error(): @@ -2228,7 +2306,9 @@ async def test_list_glossaries_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 @@ -2568,7 +2648,9 @@ def test_get_glossary_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_glossary_flattened_error(): @@ -2606,7 +2688,9 @@ async def test_get_glossary_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 @@ -2775,7 +2859,9 @@ def test_delete_glossary_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_glossary_flattened_error(): @@ -2813,7 +2899,9 @@ async def test_delete_glossary_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/tests/unit/gapic/translate_v3beta1/test_translation_service.py b/tests/unit/gapic/translate_v3beta1/test_translation_service.py index 7f70bd91..cd9ccead 100644 --- a/tests/unit/gapic/translate_v3beta1/test_translation_service.py +++ b/tests/unit/gapic/translate_v3beta1/test_translation_service.py @@ -786,9 +786,15 @@ def test_detect_language_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == "model_value" - assert args[0].mime_type == "mime_type_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].mime_type + mock_val = "mime_type_value" + assert arg == mock_val def test_detect_language_flattened_error(): @@ -831,9 +837,15 @@ async def test_detect_language_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == "model_value" - assert args[0].mime_type == "mime_type_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + arg = args[0].mime_type + mock_val = "mime_type_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1022,9 +1034,15 @@ def test_get_supported_languages_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].display_language_code == "display_language_code_value" - assert args[0].model == "model_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].display_language_code + mock_val = "display_language_code_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val def test_get_supported_languages_flattened_error(): @@ -1071,9 +1089,15 @@ async def test_get_supported_languages_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].display_language_code == "display_language_code_value" - assert args[0].model == "model_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].display_language_code + mock_val = "display_language_code_value" + assert arg == mock_val + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1568,19 +1592,29 @@ def test_batch_translate_document_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].source_language_code == "source_language_code_value" - assert args[0].target_language_codes == ["target_language_codes_value"] - assert args[0].input_configs == [ + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].source_language_code + mock_val = "source_language_code_value" + assert arg == mock_val + arg = args[0].target_language_codes + mock_val = ["target_language_codes_value"] + assert arg == mock_val + arg = args[0].input_configs + mock_val = [ translation_service.BatchDocumentInputConfig( gcs_source=translation_service.GcsSource(input_uri="input_uri_value") ) ] - assert args[0].output_config == translation_service.BatchDocumentOutputConfig( + assert arg == mock_val + arg = args[0].output_config + mock_val = translation_service.BatchDocumentOutputConfig( gcs_destination=translation_service.GcsDestination( output_uri_prefix="output_uri_prefix_value" ) ) + assert arg == mock_val def test_batch_translate_document_flattened_error(): @@ -1651,19 +1685,29 @@ async def test_batch_translate_document_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].source_language_code == "source_language_code_value" - assert args[0].target_language_codes == ["target_language_codes_value"] - assert args[0].input_configs == [ + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].source_language_code + mock_val = "source_language_code_value" + assert arg == mock_val + arg = args[0].target_language_codes + mock_val = ["target_language_codes_value"] + assert arg == mock_val + arg = args[0].input_configs + mock_val = [ translation_service.BatchDocumentInputConfig( gcs_source=translation_service.GcsSource(input_uri="input_uri_value") ) ] - assert args[0].output_config == translation_service.BatchDocumentOutputConfig( + assert arg == mock_val + arg = args[0].output_config + mock_val = translation_service.BatchDocumentOutputConfig( gcs_destination=translation_service.GcsDestination( output_uri_prefix="output_uri_prefix_value" ) ) + assert arg == mock_val @pytest.mark.asyncio @@ -1850,8 +1894,12 @@ def test_create_glossary_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].glossary == translation_service.Glossary(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].glossary + mock_val = translation_service.Glossary(name="name_value") + assert arg == mock_val def test_create_glossary_flattened_error(): @@ -1894,8 +1942,12 @@ async def test_create_glossary_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].glossary == translation_service.Glossary(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].glossary + mock_val = translation_service.Glossary(name="name_value") + assert arg == mock_val @pytest.mark.asyncio @@ -2074,8 +2126,12 @@ def test_list_glossaries_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].filter == "filter_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].filter + mock_val = "filter_value" + assert arg == mock_val def test_list_glossaries_flattened_error(): @@ -2117,8 +2173,12 @@ async def test_list_glossaries_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].filter == "filter_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].filter + mock_val = "filter_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2460,7 +2520,9 @@ def test_get_glossary_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_glossary_flattened_error(): @@ -2498,7 +2560,9 @@ async def test_get_glossary_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 @@ -2667,7 +2731,9 @@ def test_delete_glossary_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_glossary_flattened_error(): @@ -2705,7 +2771,9 @@ async def test_delete_glossary_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 From 381be6c2d0adce91831a4deda6a06cbabe70606f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 12 Nov 2021 08:53:51 -0500 Subject: [PATCH 03/26] chore(python): add .github/CODEOWNERS as a templated file (#297) Source-Link: https://github.com/googleapis/synthtool/commit/c5026b3217973a8db55db8ee85feee0e9a65e295 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:0e18b9475fbeb12d9ad4302283171edebb6baf2dfca1bd215ee3b34ed79d95d7 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .github/CODEOWNERS | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index cb89b2e3..7519fa3a 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:ec49167c606648a063d1222220b48119c912562849a0528f35bfb592a9f72737 + digest: sha256:0e18b9475fbeb12d9ad4302283171edebb6baf2dfca1bd215ee3b34ed79d95d7 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index cdf66106..b26afefd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,12 +3,10 @@ # # For syntax help see: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax +# Note: This file is autogenerated. To make changes to the codeowner team, please update .repo-metadata.json. -# The @googleapis/yoshi-python is the default owner for changes in this repo -* @googleapis/yoshi-python +# @googleapis/yoshi-python @googleapis/cdpe-cloudai are the default owners for changes in this repo +* @googleapis/yoshi-python @googleapis/cdpe-cloudai -# The @googleapis/cdpe-cloudai own the samples -/samples/**/*.py @googleapis/cdpe-cloudai - -# The python-samples-owners team is the default owner for samples -/samples/**/*.py @aribray @googleapis/python-samples-owners \ No newline at end of file +# @googleapis/python-samples-owners @googleapis/cdpe-cloudai are the default owners for samples changes +/samples/ @googleapis/python-samples-owners @googleapis/cdpe-cloudai From 1dd420ff2de38a1b5d0f556bfb7f848269b969f9 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 16 Nov 2021 12:16:30 +0100 Subject: [PATCH 04/26] chore(deps): update dependency google-cloud-texttospeech to v2.8.0 (#299) --- samples/snippets/hybrid_glossaries/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/hybrid_glossaries/requirements.txt b/samples/snippets/hybrid_glossaries/requirements.txt index cb755cb2..755fa8c8 100644 --- a/samples/snippets/hybrid_glossaries/requirements.txt +++ b/samples/snippets/hybrid_glossaries/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 google-cloud-vision==2.6.2 -google-cloud-texttospeech==2.7.1 +google-cloud-texttospeech==2.8.0 From f4a65fc5c584a7190e3b29e2cefb3df18de95afe Mon Sep 17 00:00:00 2001 From: Dan Lee <71398022+dandhlee@users.noreply.github.com> Date: Tue, 16 Nov 2021 11:00:45 -0500 Subject: [PATCH 05/26] chore: update doc links from googleapis.dev to cloud.google.com (#300) Co-authored-by: Anthonios Partheniou --- .repo-metadata.json | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index ba8cb1ea..c35665cc 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,7 +2,7 @@ "name": "translation", "name_pretty": "Cloud Translation", "product_documentation": "https://cloud.google.com/translate/docs/", - "client_documentation": "https://googleapis.dev/python/translation/latest", + "client_documentation": "https://cloud.google.com/python/docs/reference/translation/latest", "issue_tracker": "https://issuetracker.google.com/savedsearches/559749", "release_level": "ga", "language": "python", diff --git a/README.rst b/README.rst index 5fba1db0..6fd7df02 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ Cloud Translation is available as a paid service. See the `Pricing`_ and .. _Google Cloud Translation: https://cloud.google.com/translate/ .. _Pricing: https://cloud.google.com/translate/pricing .. _FAQ: https://cloud.google.com/translate/faq -.. _Client Library Documentation: https://googleapis.dev/python/translation/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/translation/latest .. _Product Documentation: https://cloud.google.com/translate/docs Quick Start From 5abc56d38d5422871325c6ab7ed80a4803b34beb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 20 Nov 2021 01:08:22 +0100 Subject: [PATCH 06/26] chore(deps): update all dependencies (#301) --- samples/snippets/hybrid_glossaries/requirements.txt | 2 +- samples/snippets/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/snippets/hybrid_glossaries/requirements.txt b/samples/snippets/hybrid_glossaries/requirements.txt index 755fa8c8..0b00fa17 100644 --- a/samples/snippets/hybrid_glossaries/requirements.txt +++ b/samples/snippets/hybrid_glossaries/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 google-cloud-vision==2.6.2 -google-cloud-texttospeech==2.8.0 +google-cloud-texttospeech==2.9.0 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index fa4d8cab..ca026cb6 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 -google-cloud-storage==1.42.3 +google-cloud-storage==1.43.0 google-cloud-automl==2.5.2 From 742e414ad8ac83e4116c67740a42e264a63e3287 Mon Sep 17 00:00:00 2001 From: orionnye Date: Mon, 22 Nov 2021 21:56:45 -0800 Subject: [PATCH 07/26] fix: 290 added a create glossary line before each call using bistro-glossary (#302) --- .../hybrid_glossaries/hybrid_tutorial_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py b/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py index 2b4f6559..8f81f325 100644 --- a/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py +++ b/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py @@ -58,6 +58,12 @@ def test_translate_standard(): expected_text = "Hello" + # attempt to create glossary, fails if it already exists + languages = ["fr", "en"] + glossary_name = "bistro-glossary" + glossary_uri = f"gs://cloud-samples-data/translation/{glossary_name}.csv" + create_glossary(languages, PROJECT_ID, glossary_name, glossary_uri) + text = translate_text("Bonjour", "fr", "en", PROJECT_ID, "bistro-glossary") assert text == expected_text @@ -68,6 +74,12 @@ def test_translate_glossary(): expected_text = "I eat goat cheese" input_text = "Je mange du chevre" + # attempt to create glossary, fails if it already exists + languages = ["fr", "en"] + glossary_name = "bistro-glossary" + glossary_uri = f"gs://cloud-samples-data/translation/{glossary_name}.csv" + create_glossary(languages, PROJECT_ID, glossary_name, glossary_uri) + text = translate_text(input_text, "fr", "en", PROJECT_ID, "bistro-glossary") assert text == expected_text From e3e0cc866b01c7a24b2f0d516c42901608f09d8a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 12 Dec 2021 12:03:30 -0500 Subject: [PATCH 08/26] chore: update python-docs-samples link to main branch (#304) Source-Link: https://github.com/googleapis/synthtool/commit/0941ef32b18aff0be34a40404f3971d9f51996e9 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2f90537dd7df70f6b663cd654b1fa5dee483cf6a4edcfd46072b2775be8a23ec Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- samples/AUTHORING_GUIDE.md | 2 +- samples/CONTRIBUTING.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7519fa3a..0b3c8cd9 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:0e18b9475fbeb12d9ad4302283171edebb6baf2dfca1bd215ee3b34ed79d95d7 + digest: sha256:2f90537dd7df70f6b663cd654b1fa5dee483cf6a4edcfd46072b2775be8a23ec diff --git a/samples/AUTHORING_GUIDE.md b/samples/AUTHORING_GUIDE.md index 55c97b32..8249522f 100644 --- a/samples/AUTHORING_GUIDE.md +++ b/samples/AUTHORING_GUIDE.md @@ -1 +1 @@ -See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md \ No newline at end of file +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md \ No newline at end of file diff --git a/samples/CONTRIBUTING.md b/samples/CONTRIBUTING.md index 34c882b6..f5fe2e6b 100644 --- a/samples/CONTRIBUTING.md +++ b/samples/CONTRIBUTING.md @@ -1 +1 @@ -See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/CONTRIBUTING.md \ No newline at end of file +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/CONTRIBUTING.md \ No newline at end of file From 513111f8c9bb1a54bb8aadecb59227421a1be12e Mon Sep 17 00:00:00 2001 From: Gal Zahavi <38544478+galz10@users.noreply.github.com> Date: Tue, 14 Dec 2021 09:56:54 -0800 Subject: [PATCH 09/26] chore: updated translate_v3beta1_translate_document sample (#308) * chore: updated translate_v3beta1_translate_document sample * lint fix * nit: changed view to output --- samples/snippets/translate_v3beta1_translate_document.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/samples/snippets/translate_v3beta1_translate_document.py b/samples/snippets/translate_v3beta1_translate_document.py index 28e28579..963d1d87 100644 --- a/samples/snippets/translate_v3beta1_translate_document.py +++ b/samples/snippets/translate_v3beta1_translate_document.py @@ -41,7 +41,11 @@ def translate_document(project_id: str, file_path: str): } ) - # To view translated document, write `response.document_translation.byte_stream_outputs` to file. + # To output the translated document, uncomment the code below. + # f = open('/tmp/output', 'wb') + # f.write(response.document_translation.byte_stream_outputs) + # f.close() + # If not provided in the TranslationRequest, the translated file will only be returned through a byte-stream # and its output mime type will be the same as the input file's mime type print("Response: Detected Language Code - {}".format(response.document_translation.detected_language_code)) From 3bd6b5d966f0a48c7517c151eae59602a23b62fe Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 28 Dec 2021 13:10:34 -0500 Subject: [PATCH 10/26] chore: update .repo-metadata.json (#309) --- .repo-metadata.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index c35665cc..58ab0eba 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -4,7 +4,7 @@ "product_documentation": "https://cloud.google.com/translate/docs/", "client_documentation": "https://cloud.google.com/python/docs/reference/translation/latest", "issue_tracker": "https://issuetracker.google.com/savedsearches/559749", - "release_level": "ga", + "release_level": "stable", "language": "python", "library_type": "GAPIC_COMBO", "repo": "googleapis/python-translate", @@ -12,5 +12,6 @@ "api_id": "translation.googleapis.com", "requires_billing": true, "default_version": "v3", - "codeowner_team": "@googleapis/cdpe-cloudai" + "codeowner_team": "@googleapis/cdpe-cloudai", + "api_shortname": "translation" } From 6d519371613f4f4a8d400968771348b70183c53a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 6 Jan 2022 17:50:13 +0000 Subject: [PATCH 11/26] chore: use python-samples-reviewers (#311) --- .github/.OwlBot.lock.yaml | 2 +- .github/CODEOWNERS | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 0b3c8cd9..f33299dd 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:2f90537dd7df70f6b663cd654b1fa5dee483cf6a4edcfd46072b2775be8a23ec + digest: sha256:899d5d7cc340fa8ef9d8ae1a8cfba362c6898584f779e156f25ee828ba824610 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b26afefd..62aced93 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -8,5 +8,5 @@ # @googleapis/yoshi-python @googleapis/cdpe-cloudai are the default owners for changes in this repo * @googleapis/yoshi-python @googleapis/cdpe-cloudai -# @googleapis/python-samples-owners @googleapis/cdpe-cloudai are the default owners for samples changes -/samples/ @googleapis/python-samples-owners @googleapis/cdpe-cloudai +# @googleapis/python-samples-reviewers @googleapis/cdpe-cloudai are the default owners for samples changes +/samples/ @googleapis/python-samples-reviewers @googleapis/cdpe-cloudai From e445cf456a47bd05c92b228c0d8da49f6f04949d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 8 Jan 2022 06:44:22 -0500 Subject: [PATCH 12/26] chore: use gapic-generator-python 0.58.4 (#310) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.58.4 fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../translation_service/transports/base.py | 1 - .../translation_service/transports/base.py | 1 - .../translate_v3/test_translation_service.py | 138 +++++++----------- .../test_translation_service.py | 138 +++++++----------- 4 files changed, 110 insertions(+), 168 deletions(-) diff --git a/google/cloud/translate_v3/services/translation_service/transports/base.py b/google/cloud/translate_v3/services/translation_service/transports/base.py index 02d30a4b..2ab577dc 100644 --- a/google/cloud/translate_v3/services/translation_service/transports/base.py +++ b/google/cloud/translate_v3/services/translation_service/transports/base.py @@ -104,7 +104,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/translate_v3beta1/services/translation_service/transports/base.py b/google/cloud/translate_v3beta1/services/translation_service/transports/base.py index 1599f819..214105b0 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/transports/base.py +++ b/google/cloud/translate_v3beta1/services/translation_service/transports/base.py @@ -104,7 +104,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/tests/unit/gapic/translate_v3/test_translation_service.py b/tests/unit/gapic/translate_v3/test_translation_service.py index 7be7d10b..5f71848f 100644 --- a/tests/unit/gapic/translate_v3/test_translation_service.py +++ b/tests/unit/gapic/translate_v3/test_translation_service.py @@ -256,20 +256,20 @@ def test_translation_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -338,7 +338,7 @@ def test_translation_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -433,7 +433,7 @@ def test_translation_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -464,7 +464,7 @@ def test_translation_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -497,9 +497,10 @@ def test_translation_service_client_client_options_from_dict(): ) -def test_translate_text( - transport: str = "grpc", request_type=translation_service.TranslateTextRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.TranslateTextRequest, dict,] +) +def test_translate_text(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -523,10 +524,6 @@ def test_translate_text( assert isinstance(response, translation_service.TranslateTextResponse) -def test_translate_text_from_dict(): - test_translate_text(request_type=dict) - - def test_translate_text_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. @@ -764,9 +761,10 @@ async def test_translate_text_flattened_error_async(): ) -def test_detect_language( - transport: str = "grpc", request_type=translation_service.DetectLanguageRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.DetectLanguageRequest, dict,] +) +def test_detect_language(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -790,10 +788,6 @@ def test_detect_language( assert isinstance(response, translation_service.DetectLanguageResponse) -def test_detect_language_from_dict(): - test_detect_language(request_type=dict) - - def test_detect_language_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. @@ -1007,10 +1001,10 @@ async def test_detect_language_flattened_error_async(): ) -def test_get_supported_languages( - transport: str = "grpc", - request_type=translation_service.GetSupportedLanguagesRequest, -): +@pytest.mark.parametrize( + "request_type", [translation_service.GetSupportedLanguagesRequest, dict,] +) +def test_get_supported_languages(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1036,10 +1030,6 @@ def test_get_supported_languages( assert isinstance(response, translation_service.SupportedLanguages) -def test_get_supported_languages_from_dict(): - test_get_supported_languages(request_type=dict) - - def test_get_supported_languages_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. @@ -1259,9 +1249,10 @@ async def test_get_supported_languages_flattened_error_async(): ) -def test_translate_document( - transport: str = "grpc", request_type=translation_service.TranslateDocumentRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.TranslateDocumentRequest, dict,] +) +def test_translate_document(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1290,10 +1281,6 @@ def test_translate_document( assert response.model == "model_value" -def test_translate_document_from_dict(): - test_translate_document(request_type=dict) - - def test_translate_document_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. @@ -1408,9 +1395,10 @@ async def test_translate_document_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_batch_translate_text( - transport: str = "grpc", request_type=translation_service.BatchTranslateTextRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.BatchTranslateTextRequest, dict,] +) +def test_batch_translate_text(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1436,10 +1424,6 @@ def test_batch_translate_text( assert isinstance(response, future.Future) -def test_batch_translate_text_from_dict(): - test_batch_translate_text(request_type=dict) - - def test_batch_translate_text_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. @@ -1553,10 +1537,10 @@ async def test_batch_translate_text_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_batch_translate_document( - transport: str = "grpc", - request_type=translation_service.BatchTranslateDocumentRequest, -): +@pytest.mark.parametrize( + "request_type", [translation_service.BatchTranslateDocumentRequest, dict,] +) +def test_batch_translate_document(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1582,10 +1566,6 @@ def test_batch_translate_document( assert isinstance(response, future.Future) -def test_batch_translate_document_from_dict(): - test_batch_translate_document(request_type=dict) - - def test_batch_translate_document_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. @@ -1881,9 +1861,10 @@ async def test_batch_translate_document_flattened_error_async(): ) -def test_create_glossary( - transport: str = "grpc", request_type=translation_service.CreateGlossaryRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.CreateGlossaryRequest, dict,] +) +def test_create_glossary(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1907,10 +1888,6 @@ def test_create_glossary( assert isinstance(response, future.Future) -def test_create_glossary_from_dict(): - test_create_glossary(request_type=dict) - - def test_create_glossary_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. @@ -2108,9 +2085,10 @@ async def test_create_glossary_flattened_error_async(): ) -def test_list_glossaries( - transport: str = "grpc", request_type=translation_service.ListGlossariesRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.ListGlossariesRequest, dict,] +) +def test_list_glossaries(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2137,10 +2115,6 @@ def test_list_glossaries( assert response.next_page_token == "next_page_token_value" -def test_list_glossaries_from_dict(): - test_list_glossaries(request_type=dict) - - def test_list_glossaries_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. @@ -2325,8 +2299,10 @@ async def test_list_glossaries_flattened_error_async(): ) -def test_list_glossaries_pager(): - client = TranslationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_glossaries_pager(transport_name: str = "grpc"): + client = TranslationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_glossaries), "__call__") as call: @@ -2368,8 +2344,10 @@ def test_list_glossaries_pager(): assert all(isinstance(i, translation_service.Glossary) for i in results) -def test_list_glossaries_pages(): - client = TranslationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_glossaries_pages(transport_name: str = "grpc"): + client = TranslationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_glossaries), "__call__") as call: @@ -2487,9 +2465,10 @@ async def test_list_glossaries_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_glossary( - transport: str = "grpc", request_type=translation_service.GetGlossaryRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.GetGlossaryRequest, dict,] +) +def test_get_glossary(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2521,10 +2500,6 @@ def test_get_glossary( assert response.entry_count == 1210 -def test_get_glossary_from_dict(): - test_get_glossary(request_type=dict) - - def test_get_glossary_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. @@ -2707,9 +2682,10 @@ async def test_get_glossary_flattened_error_async(): ) -def test_delete_glossary( - transport: str = "grpc", request_type=translation_service.DeleteGlossaryRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.DeleteGlossaryRequest, dict,] +) +def test_delete_glossary(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2733,10 +2709,6 @@ def test_delete_glossary( assert isinstance(response, future.Future) -def test_delete_glossary_from_dict(): - test_delete_glossary(request_type=dict) - - def test_delete_glossary_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. @@ -3488,7 +3460,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( diff --git a/tests/unit/gapic/translate_v3beta1/test_translation_service.py b/tests/unit/gapic/translate_v3beta1/test_translation_service.py index cd9ccead..736e2b5d 100644 --- a/tests/unit/gapic/translate_v3beta1/test_translation_service.py +++ b/tests/unit/gapic/translate_v3beta1/test_translation_service.py @@ -256,20 +256,20 @@ def test_translation_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -338,7 +338,7 @@ def test_translation_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -433,7 +433,7 @@ def test_translation_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -464,7 +464,7 @@ def test_translation_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -497,9 +497,10 @@ def test_translation_service_client_client_options_from_dict(): ) -def test_translate_text( - transport: str = "grpc", request_type=translation_service.TranslateTextRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.TranslateTextRequest, dict,] +) +def test_translate_text(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -523,10 +524,6 @@ def test_translate_text( assert isinstance(response, translation_service.TranslateTextResponse) -def test_translate_text_from_dict(): - test_translate_text(request_type=dict) - - def test_translate_text_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. @@ -632,9 +629,10 @@ async def test_translate_text_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_detect_language( - transport: str = "grpc", request_type=translation_service.DetectLanguageRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.DetectLanguageRequest, dict,] +) +def test_detect_language(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -658,10 +656,6 @@ def test_detect_language( assert isinstance(response, translation_service.DetectLanguageResponse) -def test_detect_language_from_dict(): - test_detect_language(request_type=dict) - - def test_detect_language_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. @@ -865,10 +859,10 @@ async def test_detect_language_flattened_error_async(): ) -def test_get_supported_languages( - transport: str = "grpc", - request_type=translation_service.GetSupportedLanguagesRequest, -): +@pytest.mark.parametrize( + "request_type", [translation_service.GetSupportedLanguagesRequest, dict,] +) +def test_get_supported_languages(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -894,10 +888,6 @@ def test_get_supported_languages( assert isinstance(response, translation_service.SupportedLanguages) -def test_get_supported_languages_from_dict(): - test_get_supported_languages(request_type=dict) - - def test_get_supported_languages_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. @@ -1117,9 +1107,10 @@ async def test_get_supported_languages_flattened_error_async(): ) -def test_translate_document( - transport: str = "grpc", request_type=translation_service.TranslateDocumentRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.TranslateDocumentRequest, dict,] +) +def test_translate_document(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1148,10 +1139,6 @@ def test_translate_document( assert response.model == "model_value" -def test_translate_document_from_dict(): - test_translate_document(request_type=dict) - - def test_translate_document_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. @@ -1266,9 +1253,10 @@ async def test_translate_document_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_batch_translate_text( - transport: str = "grpc", request_type=translation_service.BatchTranslateTextRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.BatchTranslateTextRequest, dict,] +) +def test_batch_translate_text(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1294,10 +1282,6 @@ def test_batch_translate_text( assert isinstance(response, future.Future) -def test_batch_translate_text_from_dict(): - test_batch_translate_text(request_type=dict) - - def test_batch_translate_text_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. @@ -1411,10 +1395,10 @@ async def test_batch_translate_text_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_batch_translate_document( - transport: str = "grpc", - request_type=translation_service.BatchTranslateDocumentRequest, -): +@pytest.mark.parametrize( + "request_type", [translation_service.BatchTranslateDocumentRequest, dict,] +) +def test_batch_translate_document(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1440,10 +1424,6 @@ def test_batch_translate_document( assert isinstance(response, future.Future) -def test_batch_translate_document_from_dict(): - test_batch_translate_document(request_type=dict) - - def test_batch_translate_document_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. @@ -1739,9 +1719,10 @@ async def test_batch_translate_document_flattened_error_async(): ) -def test_create_glossary( - transport: str = "grpc", request_type=translation_service.CreateGlossaryRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.CreateGlossaryRequest, dict,] +) +def test_create_glossary(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1765,10 +1746,6 @@ def test_create_glossary( assert isinstance(response, future.Future) -def test_create_glossary_from_dict(): - test_create_glossary(request_type=dict) - - def test_create_glossary_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. @@ -1966,9 +1943,10 @@ async def test_create_glossary_flattened_error_async(): ) -def test_list_glossaries( - transport: str = "grpc", request_type=translation_service.ListGlossariesRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.ListGlossariesRequest, dict,] +) +def test_list_glossaries(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1995,10 +1973,6 @@ def test_list_glossaries( assert response.next_page_token == "next_page_token_value" -def test_list_glossaries_from_dict(): - test_list_glossaries(request_type=dict) - - def test_list_glossaries_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. @@ -2197,8 +2171,10 @@ async def test_list_glossaries_flattened_error_async(): ) -def test_list_glossaries_pager(): - client = TranslationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_glossaries_pager(transport_name: str = "grpc"): + client = TranslationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_glossaries), "__call__") as call: @@ -2240,8 +2216,10 @@ def test_list_glossaries_pager(): assert all(isinstance(i, translation_service.Glossary) for i in results) -def test_list_glossaries_pages(): - client = TranslationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_glossaries_pages(transport_name: str = "grpc"): + client = TranslationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_glossaries), "__call__") as call: @@ -2359,9 +2337,10 @@ async def test_list_glossaries_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_glossary( - transport: str = "grpc", request_type=translation_service.GetGlossaryRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.GetGlossaryRequest, dict,] +) +def test_get_glossary(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2393,10 +2372,6 @@ def test_get_glossary( assert response.entry_count == 1210 -def test_get_glossary_from_dict(): - test_get_glossary(request_type=dict) - - def test_get_glossary_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. @@ -2579,9 +2554,10 @@ async def test_get_glossary_flattened_error_async(): ) -def test_delete_glossary( - transport: str = "grpc", request_type=translation_service.DeleteGlossaryRequest -): +@pytest.mark.parametrize( + "request_type", [translation_service.DeleteGlossaryRequest, dict,] +) +def test_delete_glossary(request_type, transport: str = "grpc"): client = TranslationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2605,10 +2581,6 @@ def test_delete_glossary( assert isinstance(response, future.Future) -def test_delete_glossary_from_dict(): - test_delete_glossary(request_type=dict) - - def test_delete_glossary_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. @@ -3360,7 +3332,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( From d8e555d4366acd2293018883c909736fc9d113b2 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 11 Jan 2022 15:59:26 +0100 Subject: [PATCH 13/26] chore(deps): update all dependencies (#307) --- samples/snippets/hybrid_glossaries/requirements.txt | 2 +- samples/snippets/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/snippets/hybrid_glossaries/requirements.txt b/samples/snippets/hybrid_glossaries/requirements.txt index 0b00fa17..86539209 100644 --- a/samples/snippets/hybrid_glossaries/requirements.txt +++ b/samples/snippets/hybrid_glossaries/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 -google-cloud-vision==2.6.2 +google-cloud-vision==2.6.3 google-cloud-texttospeech==2.9.0 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index ca026cb6..324c4889 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 -google-cloud-storage==1.43.0 +google-cloud-storage==1.44.0 google-cloud-automl==2.5.2 From 96629c9cef1bef808b5b72db5022ce465351eb9a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 10:32:35 -0500 Subject: [PATCH 14/26] chore(python): fix undefined name 'glob' in samples noxfile (#314) Source-Link: https://github.com/googleapis/synthtool/commit/52aef91f8d25223d9dbdb4aebd94ba8eea2101f3 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:36a95b8f494e4674dc9eee9af98961293b51b86b3649942aac800ae6c1f796d4 Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .github/.OwlBot.lock.yaml | 2 +- samples/snippets/hybrid_glossaries/noxfile.py | 70 +++++++++++-------- samples/snippets/noxfile.py | 70 +++++++++++-------- 3 files changed, 79 insertions(+), 63 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index f33299dd..6b8a73b3 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:899d5d7cc340fa8ef9d8ae1a8cfba362c6898584f779e156f25ee828ba824610 + digest: sha256:36a95b8f494e4674dc9eee9af98961293b51b86b3649942aac800ae6c1f796d4 diff --git a/samples/snippets/hybrid_glossaries/noxfile.py b/samples/snippets/hybrid_glossaries/noxfile.py index 93a9122c..3bbef5d5 100644 --- a/samples/snippets/hybrid_glossaries/noxfile.py +++ b/samples/snippets/hybrid_glossaries/noxfile.py @@ -14,6 +14,7 @@ from __future__ import print_function +import glob import os from pathlib import Path import sys @@ -184,37 +185,44 @@ def blacken(session: nox.sessions.Session) -> None: def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + # check for presence of tests + test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + if len(test_list) == 0: + print("No tests found, skipping directory.") + else: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 93a9122c..3bbef5d5 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -14,6 +14,7 @@ from __future__ import print_function +import glob import os from pathlib import Path import sys @@ -184,37 +185,44 @@ def blacken(session: nox.sessions.Session) -> None: def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + # check for presence of tests + test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + if len(test_list) == 0: + print("No tests found, skipping directory.") + else: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) From ab6f9c3acb837bc8298553e81ca32faa38c9948f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 12:46:11 +0000 Subject: [PATCH 15/26] chore(python): update release.sh to use keystore (#320) build: switch to release-please for tagging --- .github/.OwlBot.lock.yaml | 2 +- .github/release-please.yml | 1 + .github/release-trigger.yml | 1 + .kokoro/release.sh | 2 +- .kokoro/release/common.cfg | 12 +++++++++++- 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .github/release-trigger.yml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 6b8a73b3..eecb84c2 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:36a95b8f494e4674dc9eee9af98961293b51b86b3649942aac800ae6c1f796d4 + digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 diff --git a/.github/release-please.yml b/.github/release-please.yml index 4507ad05..466597e5 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1 +1,2 @@ releaseType: python +handleGHRelease: true diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml new file mode 100644 index 00000000..d4ca9418 --- /dev/null +++ b/.github/release-trigger.yml @@ -0,0 +1 @@ +enabled: true diff --git a/.kokoro/release.sh b/.kokoro/release.sh index a47e93f4..64f8b6a3 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") cd github/python-translate python3 setup.py sdist bdist_wheel twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 11473f0a..9c7e0965 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,8 +23,18 @@ env_vars: { value: "github/python-translate/.kokoro/release.sh" } +# Fetch PyPI password +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "google-cloud-pypi-token-keystore-1" + } + } +} + # Tokens needed to report release status back to GitHub env_vars: { key: "SECRET_MANAGER_KEYS" - value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } From 42478381c0773132b3dc0c877bc7bd31a3938811 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 17 Jan 2022 17:34:18 +0100 Subject: [PATCH 16/26] chore(deps): update dependency google-cloud-storage to v2 (#318) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 324c4889..390316bb 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 -google-cloud-storage==1.44.0 +google-cloud-storage==2.0.0 google-cloud-automl==2.5.2 From 155eb08d54c2054f52b84ec4d73d1971d5def036 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 19 Jan 2022 00:13:33 +0100 Subject: [PATCH 17/26] chore(deps): update dependency google-cloud-automl to v2.6.0 (#322) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 390316bb..0b3e1b5d 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 google-cloud-storage==2.0.0 -google-cloud-automl==2.5.2 +google-cloud-automl==2.6.0 From 917c8224ab632515a1bac5b439da1736b578b216 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 18 Jan 2022 20:39:53 -0500 Subject: [PATCH 18/26] chore(python): Noxfile recognizes that tests can live in a folder (#323) Source-Link: https://github.com/googleapis/synthtool/commit/4760d8dce1351d93658cb11d02a1b7ceb23ae5d7 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- samples/snippets/hybrid_glossaries/noxfile.py | 1 + samples/snippets/noxfile.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index eecb84c2..52d79c11 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 + digest: sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828 diff --git a/samples/snippets/hybrid_glossaries/noxfile.py b/samples/snippets/hybrid_glossaries/noxfile.py index 3bbef5d5..20cdfc62 100644 --- a/samples/snippets/hybrid_glossaries/noxfile.py +++ b/samples/snippets/hybrid_glossaries/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 3bbef5d5..20cdfc62 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: From 1834d0646ba9467426e603918c6deef19f141998 Mon Sep 17 00:00:00 2001 From: wesley chun Date: Wed, 19 Jan 2022 01:42:02 -0800 Subject: [PATCH 19/26] chore: add samples/cloud-nebulous-serverless/README.md (#312) * connect Python Translate client library to nebulous serverless example * added Samples section to README * fix path * update README * fix README link * move sample info to README * fix RST formatting * chore: update RST for Sphinx lint * chore: update README for RST style * updated serverless sample README Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com> Co-authored-by: Anthonios Partheniou --- samples/cloud-nebulous-serverless-python/README.md | 1 - samples/cloud-nebulous-serverless/README.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 samples/cloud-nebulous-serverless-python/README.md create mode 100644 samples/cloud-nebulous-serverless/README.md diff --git a/samples/cloud-nebulous-serverless-python/README.md b/samples/cloud-nebulous-serverless-python/README.md deleted file mode 100644 index 9dfab667..00000000 --- a/samples/cloud-nebulous-serverless-python/README.md +++ /dev/null @@ -1 +0,0 @@ -This sample can be found at . diff --git a/samples/cloud-nebulous-serverless/README.md b/samples/cloud-nebulous-serverless/README.md new file mode 100644 index 00000000..e2c82823 --- /dev/null +++ b/samples/cloud-nebulous-serverless/README.md @@ -0,0 +1 @@ +This sample, demonstrating how to access the [Cloud Translation API](https://cloud.google.com/translate) from [Google Cloud serverless platforms](https://cloud.google.com/serverless) (App Engine, Cloud Functions, Cloud Run) can be found at . Versions in Python (2.7 and 3.7+) and Node.js (10+) are available along with hands-on tutorials. From 834f2c6fdc54bcf55dcc5fae9947d7cb1b003422 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 19 Jan 2022 14:18:32 +0100 Subject: [PATCH 20/26] chore(deps): update dependency google-cloud-texttospeech to v2.9.1 (#324) Co-authored-by: Anthonios Partheniou --- samples/snippets/hybrid_glossaries/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/hybrid_glossaries/requirements.txt b/samples/snippets/hybrid_glossaries/requirements.txt index 86539209..945d36de 100644 --- a/samples/snippets/hybrid_glossaries/requirements.txt +++ b/samples/snippets/hybrid_glossaries/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 google-cloud-vision==2.6.3 -google-cloud-texttospeech==2.9.0 +google-cloud-texttospeech==2.9.1 From 3d12a178c578e8abce22d9634ca3beea536e62bc Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 20 Jan 2022 10:14:41 -0500 Subject: [PATCH 21/26] ci(python): run lint / unit tests / docs as GH actions (#326) * ci(python): run lint / unit tests / docs as GH actions Source-Link: https://github.com/googleapis/synthtool/commit/57be0cdb0b94e1669cee0ca38d790de1dfdbcd44 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 * add a commit to activate gh actions * workaround bug in templates Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .github/.OwlBot.lock.yaml | 16 +++++++++- .github/workflows/docs.yml | 38 +++++++++++++++++++++++ .github/workflows/lint.yml | 25 +++++++++++++++ .github/workflows/unittest.yml | 57 ++++++++++++++++++++++++++++++++++ owlbot.py | 3 ++ 5 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/unittest.yml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 52d79c11..b668c04d 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828 + digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 + diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..f7b8344c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - main +name: docs +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docs + run: | + nox -s docs + docfx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docfx + run: | + nox -s docfx diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1e8b05c3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - main +name: lint +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run lint + run: | + nox -s lint + - name: Run lint_setup_py + run: | + nox -s lint_setup_py diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 00000000..e84424b8 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - main +name: unittest +jobs: + unit: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-results/ + - name: Report coverage results + run: | + coverage combine .coverage-results/.coverage* + coverage report --show-missing --fail-under=99 diff --git a/owlbot.py b/owlbot.py index d960cf99..d329fa9e 100644 --- a/owlbot.py +++ b/owlbot.py @@ -66,6 +66,9 @@ ) s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file +# Work around bug in templates https://github.com/googleapis/synthtool/pull/1335 +s.replace(".github/workflows/unittest.yml", "--fail-under=100", "--fail-under=99") + # ---------------------------------------------------------------------------- # Samples templates # ---------------------------------------------------------------------------- From d41464019821f598fc4a5c08df6baaa3ee2a0088 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:08:16 -0700 Subject: [PATCH 22/26] chore: make samples 3.6 check optional (#328) --- .github/sync-repo-settings.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 3e98ae70..37438d33 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -10,6 +10,5 @@ branchProtectionRules: - 'Kokoro' - 'cla/google' - 'Samples - Lint' - - 'Samples - Python 3.6' - 'Samples - Python 3.7' - 'Samples - Python 3.8' From 4b08cd56ce230b843ced78a3f81c2e6511ac2a4f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 25 Jan 2022 10:33:20 -0500 Subject: [PATCH 23/26] feat: add api key support (#329) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: upgrade gapic-generator-java, gax-java and gapic-generator-python PiperOrigin-RevId: 423842556 Source-Link: https://github.com/googleapis/googleapis/commit/a616ca08f4b1416abbac7bc5dd6d61c791756a81 Source-Link: https://github.com/googleapis/googleapis-gen/commit/29b938c58c1e51d019f2ee539d55dc0a3c86a905 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjliOTM4YzU4YzFlNTFkMDE5ZjJlZTUzOWQ1NWRjMGEzYzg2YTkwNSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .../translation_service/async_client.py | 38 ++++- .../services/translation_service/client.py | 127 +++++++++++------ .../translation_service/async_client.py | 38 ++++- .../services/translation_service/client.py | 127 +++++++++++------ .../translate_v3/test_translation_service.py | 131 ++++++++++++++++++ .../test_translation_service.py | 131 ++++++++++++++++++ 6 files changed, 504 insertions(+), 88 deletions(-) diff --git a/google/cloud/translate_v3/services/translation_service/async_client.py b/google/cloud/translate_v3/services/translation_service/async_client.py index a9ef6b4c..9b445803 100644 --- a/google/cloud/translate_v3/services/translation_service/async_client.py +++ b/google/cloud/translate_v3/services/translation_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -109,6 +109,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return TranslationServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> TranslationServiceTransport: """Returns the transport used by the client instance. diff --git a/google/cloud/translate_v3/services/translation_service/client.py b/google/cloud/translate_v3/services/translation_service/client.py index 22667161..f72e015e 100644 --- a/google/cloud/translate_v3/services/translation_service/client.py +++ b/google/cloud/translate_v3/services/translation_service/client.py @@ -239,6 +239,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -289,57 +356,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - 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" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, TranslationServiceTransport): # transport is a TranslationServiceTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -351,6 +383,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, diff --git a/google/cloud/translate_v3beta1/services/translation_service/async_client.py b/google/cloud/translate_v3beta1/services/translation_service/async_client.py index 275d0de0..a080e88c 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/async_client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -109,6 +109,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return TranslationServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> TranslationServiceTransport: """Returns the transport used by the client instance. diff --git a/google/cloud/translate_v3beta1/services/translation_service/client.py b/google/cloud/translate_v3beta1/services/translation_service/client.py index 1df2ed28..4290ff2b 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/client.py @@ -239,6 +239,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -289,57 +356,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - 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" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, TranslationServiceTransport): # transport is a TranslationServiceTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -351,6 +383,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, diff --git a/tests/unit/gapic/translate_v3/test_translation_service.py b/tests/unit/gapic/translate_v3/test_translation_service.py index 5f71848f..7f002508 100644 --- a/tests/unit/gapic/translate_v3/test_translation_service.py +++ b/tests/unit/gapic/translate_v3/test_translation_service.py @@ -415,6 +415,87 @@ def test_translation_service_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [TranslationServiceClient, TranslationServiceAsyncClient] +) +@mock.patch.object( + TranslationServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TranslationServiceClient), +) +@mock.patch.object( + TranslationServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TranslationServiceAsyncClient), +) +def test_translation_service_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -2910,6 +2991,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.TranslationServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TranslationServiceClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TranslationServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.TranslationServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3525,3 +3623,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (TranslationServiceClient, transports.TranslationServiceGrpcTransport), + ( + TranslationServiceAsyncClient, + transports.TranslationServiceGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/translate_v3beta1/test_translation_service.py b/tests/unit/gapic/translate_v3beta1/test_translation_service.py index 736e2b5d..a3ab8808 100644 --- a/tests/unit/gapic/translate_v3beta1/test_translation_service.py +++ b/tests/unit/gapic/translate_v3beta1/test_translation_service.py @@ -415,6 +415,87 @@ def test_translation_service_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [TranslationServiceClient, TranslationServiceAsyncClient] +) +@mock.patch.object( + TranslationServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TranslationServiceClient), +) +@mock.patch.object( + TranslationServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TranslationServiceAsyncClient), +) +def test_translation_service_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -2782,6 +2863,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.TranslationServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TranslationServiceClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TranslationServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.TranslationServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3397,3 +3495,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (TranslationServiceClient, transports.TranslationServiceGrpcTransport), + ( + TranslationServiceAsyncClient, + transports.TranslationServiceGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) From 26791c251e851f921d23316e6ca5adab648c63c0 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 3 Feb 2022 15:24:55 +0000 Subject: [PATCH 24/26] chore: use gapic-generator-python 0.62.1 (#333) - [ ] Regenerate this pull request now. fix: resolve DuplicateCredentialArgs error when using credentials_file committer: parthea PiperOrigin-RevId: 425964861 Source-Link: https://github.com/googleapis/googleapis/commit/84b1a5a4f6fb2d04905be58e586b8a7a4310a8cf Source-Link: https://github.com/googleapis/googleapis-gen/commit/4fb761bbd8506ac156f49bac5f18306aa8eb3aa8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9 --- .../translation_service/async_client.py | 16 ++-- .../services/translation_service/client.py | 16 ++-- .../translation_service/transports/grpc.py | 7 +- .../transports/grpc_asyncio.py | 7 +- .../translate_v3/types/translation_service.py | 5 +- .../translation_service/async_client.py | 24 +++--- .../services/translation_service/client.py | 24 +++--- .../translation_service/transports/grpc.py | 17 ++-- .../transports/grpc_asyncio.py | 17 ++-- .../types/translation_service.py | 5 +- .../translate_v3/test_translation_service.py | 83 ++++++++++++++++++- .../test_translation_service.py | 83 ++++++++++++++++++- 12 files changed, 236 insertions(+), 68 deletions(-) diff --git a/google/cloud/translate_v3/services/translation_service/async_client.py b/google/cloud/translate_v3/services/translation_service/async_client.py index 9b445803..f1fa93b9 100644 --- a/google/cloud/translate_v3/services/translation_service/async_client.py +++ b/google/cloud/translate_v3/services/translation_service/async_client.py @@ -321,7 +321,7 @@ async def translate_text( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [ @@ -457,7 +457,7 @@ async def detect_language( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model, mime_type, content]) if request is not None and has_flattened_params: @@ -578,7 +578,7 @@ async def get_supported_languages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model, display_language_code]) if request is not None and has_flattened_params: @@ -844,7 +844,7 @@ async def batch_translate_document( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [ @@ -946,7 +946,7 @@ async def create_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, glossary]) if request is not None and has_flattened_params: @@ -1030,7 +1030,7 @@ async def list_glossaries( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1117,7 +1117,7 @@ async def get_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1202,7 +1202,7 @@ async def delete_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/translate_v3/services/translation_service/client.py b/google/cloud/translate_v3/services/translation_service/client.py index f72e015e..420622d7 100644 --- a/google/cloud/translate_v3/services/translation_service/client.py +++ b/google/cloud/translate_v3/services/translation_service/client.py @@ -519,7 +519,7 @@ def translate_text( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [ @@ -655,7 +655,7 @@ def detect_language( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model, mime_type, content]) if request is not None and has_flattened_params: @@ -776,7 +776,7 @@ def get_supported_languages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model, display_language_code]) if request is not None and has_flattened_params: @@ -1034,7 +1034,7 @@ def batch_translate_document( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [ @@ -1136,7 +1136,7 @@ def create_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, glossary]) if request is not None and has_flattened_params: @@ -1220,7 +1220,7 @@ def list_glossaries( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1297,7 +1297,7 @@ def get_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1372,7 +1372,7 @@ def delete_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/translate_v3/services/translation_service/transports/grpc.py b/google/cloud/translate_v3/services/translation_service/transports/grpc.py index e608b61f..9beb6d58 100644 --- a/google/cloud/translate_v3/services/translation_service/transports/grpc.py +++ b/google/cloud/translate_v3/services/translation_service/transports/grpc.py @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -235,7 +238,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py b/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py index 68c4840b..c875f91f 100644 --- a/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py +++ b/google/cloud/translate_v3/services/translation_service/transports/grpc_asyncio.py @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -237,7 +240,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/translate_v3/types/translation_service.py b/google/cloud/translate_v3/types/translation_service.py index 66c24dce..8e52d14a 100644 --- a/google/cloud/translate_v3/types/translation_service.py +++ b/google/cloud/translate_v3/types/translation_service.py @@ -76,8 +76,9 @@ class TranslateTextGlossaryConfig(proto.Message): - User provided custom glossary: ``projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`` ignore_case (bool): - Optional. Indicates match is case- - nsensitive. Default value is false if missing. + Optional. Indicates match is + case-insensitive. Default value is false if + missing. """ glossary = proto.Field(proto.STRING, number=1,) diff --git a/google/cloud/translate_v3beta1/services/translation_service/async_client.py b/google/cloud/translate_v3beta1/services/translation_service/async_client.py index a080e88c..8c8c2eeb 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/async_client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/async_client.py @@ -326,7 +326,7 @@ async def detect_language( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model, mime_type]) if request is not None and has_flattened_params: @@ -445,7 +445,7 @@ async def get_supported_languages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, display_language_code, model]) if request is not None and has_flattened_params: @@ -625,11 +625,11 @@ async def batch_translate_document( metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Translates a large volume of documents in - asynchronous batch mode. This function provides real- - time output as the inputs are being processed. If caller - cancels a request, the partial results (for an input - file, it's all or nothing) may still be available on the - specified output location. + asynchronous batch mode. This function provides + real-time output as the inputs are being processed. If + caller cancels a request, the partial results (for an + input file, it's all or nothing) may still be available + on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call. @@ -711,7 +711,7 @@ async def batch_translate_document( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [ @@ -813,7 +813,7 @@ async def create_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, glossary]) if request is not None and has_flattened_params: @@ -932,7 +932,7 @@ async def list_glossaries( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, filter]) if request is not None and has_flattened_params: @@ -1021,7 +1021,7 @@ async def get_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1106,7 +1106,7 @@ async def delete_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/translate_v3beta1/services/translation_service/client.py b/google/cloud/translate_v3beta1/services/translation_service/client.py index 4290ff2b..2fb395cb 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/client.py @@ -525,7 +525,7 @@ def detect_language( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model, mime_type]) if request is not None and has_flattened_params: @@ -644,7 +644,7 @@ def get_supported_languages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, display_language_code, model]) if request is not None and has_flattened_params: @@ -816,11 +816,11 @@ def batch_translate_document( metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Translates a large volume of documents in - asynchronous batch mode. This function provides real- - time output as the inputs are being processed. If caller - cancels a request, the partial results (for an input - file, it's all or nothing) may still be available on the - specified output location. + asynchronous batch mode. This function provides + real-time output as the inputs are being processed. If + caller cancels a request, the partial results (for an + input file, it's all or nothing) may still be available + on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call. @@ -902,7 +902,7 @@ def batch_translate_document( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any( [ @@ -1004,7 +1004,7 @@ def create_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, glossary]) if request is not None and has_flattened_params: @@ -1123,7 +1123,7 @@ def list_glossaries( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, filter]) if request is not None and has_flattened_params: @@ -1202,7 +1202,7 @@ def get_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1277,7 +1277,7 @@ def delete_glossary( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py b/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py index 89303173..d11df630 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py +++ b/google/cloud/translate_v3beta1/services/translation_service/transports/grpc.py @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -235,7 +238,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) @@ -404,11 +407,11 @@ def batch_translate_document( r"""Return a callable for the batch translate document method over gRPC. Translates a large volume of documents in - asynchronous batch mode. This function provides real- - time output as the inputs are being processed. If caller - cancels a request, the partial results (for an input - file, it's all or nothing) may still be available on the - specified output location. + asynchronous batch mode. This function provides + real-time output as the inputs are being processed. If + caller cancels a request, the partial results (for an + input file, it's all or nothing) may still be available + on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call. diff --git a/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py b/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py index a17b04da..3aec3e8b 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py +++ b/google/cloud/translate_v3beta1/services/translation_service/transports/grpc_asyncio.py @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -237,7 +240,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel @@ -410,11 +413,11 @@ def batch_translate_document( r"""Return a callable for the batch translate document method over gRPC. Translates a large volume of documents in - asynchronous batch mode. This function provides real- - time output as the inputs are being processed. If caller - cancels a request, the partial results (for an input - file, it's all or nothing) may still be available on the - specified output location. + asynchronous batch mode. This function provides + real-time output as the inputs are being processed. If + caller cancels a request, the partial results (for an + input file, it's all or nothing) may still be available + on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call. diff --git a/google/cloud/translate_v3beta1/types/translation_service.py b/google/cloud/translate_v3beta1/types/translation_service.py index f894223a..ac51e013 100644 --- a/google/cloud/translate_v3beta1/types/translation_service.py +++ b/google/cloud/translate_v3beta1/types/translation_service.py @@ -71,8 +71,9 @@ class TranslateTextGlossaryConfig(proto.Message): Required. Specifies the glossary used for this translation. Use this format: projects/\ */locations/*/glossaries/\* ignore_case (bool): - Optional. Indicates match is case- - nsensitive. Default value is false if missing. + Optional. Indicates match is + case-insensitive. Default value is false if + missing. """ glossary = proto.Field(proto.STRING, number=1,) diff --git a/tests/unit/gapic/translate_v3/test_translation_service.py b/tests/unit/gapic/translate_v3/test_translation_service.py index 7f002508..b82ff411 100644 --- a/tests/unit/gapic/translate_v3/test_translation_service.py +++ b/tests/unit/gapic/translate_v3/test_translation_service.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -528,21 +529,28 @@ def test_translation_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (TranslationServiceClient, transports.TranslationServiceGrpcTransport, "grpc"), + ( + TranslationServiceClient, + transports.TranslationServiceGrpcTransport, + "grpc", + grpc_helpers, + ), ( TranslationServiceAsyncClient, transports.TranslationServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_translation_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -578,6 +586,75 @@ def test_translation_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + TranslationServiceClient, + transports.TranslationServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + TranslationServiceAsyncClient, + transports.TranslationServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_translation_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "translate.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-translation", + ), + scopes=None, + default_host="translate.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [translation_service.TranslateTextRequest, dict,] ) diff --git a/tests/unit/gapic/translate_v3beta1/test_translation_service.py b/tests/unit/gapic/translate_v3beta1/test_translation_service.py index a3ab8808..ec260dcd 100644 --- a/tests/unit/gapic/translate_v3beta1/test_translation_service.py +++ b/tests/unit/gapic/translate_v3beta1/test_translation_service.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -528,21 +529,28 @@ def test_translation_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (TranslationServiceClient, transports.TranslationServiceGrpcTransport, "grpc"), + ( + TranslationServiceClient, + transports.TranslationServiceGrpcTransport, + "grpc", + grpc_helpers, + ), ( TranslationServiceAsyncClient, transports.TranslationServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_translation_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -578,6 +586,75 @@ def test_translation_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + TranslationServiceClient, + transports.TranslationServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + TranslationServiceAsyncClient, + transports.TranslationServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_translation_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "translate.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-translation", + ), + scopes=None, + default_host="translate.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [translation_service.TranslateTextRequest, dict,] ) From 50833e45c222ec2db0ea13ea569fd9cf58caf052 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 3 Feb 2022 17:04:56 +0100 Subject: [PATCH 25/26] chore(deps): update all dependencies (#325) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [google-cloud-storage](https://togithub.com/googleapis/python-storage) | `==2.0.0` -> `==2.1.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/compatibility-slim/2.0.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/confidence-slim/2.0.0)](https://docs.renovatebot.com/merge-confidence/) | | [google-cloud-texttospeech](https://togithub.com/googleapis/python-texttospeech) | `==2.9.1` -> `==2.10.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-texttospeech/2.10.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-texttospeech/2.10.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-texttospeech/2.10.0/compatibility-slim/2.9.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-texttospeech/2.10.0/confidence-slim/2.9.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/python-storage ### [`v2.1.0`](https://togithub.com/googleapis/python-storage/blob/HEAD/CHANGELOG.md#​210-httpsgithubcomgoogleapispython-storagecomparev200v210-2022-01-19) [Compare Source](https://togithub.com/googleapis/python-storage/compare/v2.0.0...v2.1.0) ##### Features - add turbo replication support and samples ([#​622](https://togithub.com/googleapis/python-storage/issues/622)) ([4dafc81](https://togithub.com/googleapis/python-storage/commit/4dafc815470480ce9de7f0357e331d3fbd0ae9b7)) - avoid authentication with storage emulator ([#​679](https://togithub.com/googleapis/python-storage/issues/679)) ([8789afa](https://togithub.com/googleapis/python-storage/commit/8789afaaa1b2bd6f03fae72e3d87ce004ec10129)) - remove python 3.6 support ([#​689](https://togithub.com/googleapis/python-storage/issues/689)) ([8aa4130](https://togithub.com/googleapis/python-storage/commit/8aa4130ee068a1922161c8ca54a53a4a51d65ce0))
googleapis/python-texttospeech ### [`v2.10.0`](https://togithub.com/googleapis/python-texttospeech/blob/HEAD/CHANGELOG.md#​2100-httpsgithubcomgoogleapispython-texttospeechcomparev291v2100-2022-02-03) [Compare Source](https://togithub.com/googleapis/python-texttospeech/compare/v2.9.1...v2.10.0) ##### Features - add api key support ([#​242](https://togithub.com/googleapis/python-texttospeech/issues/242)) ([3b4f0d0](https://togithub.com/googleapis/python-texttospeech/commit/3b4f0d0749529b04ed7fedec3c4b06b6d42c12cd)) ##### Bug Fixes - resolve DuplicateCredentialArgs error when using credentials_file ([4c11b12](https://togithub.com/googleapis/python-texttospeech/commit/4c11b127ece0009082fe91062f3f36c8f18e8ffc)) ##### Documentation - update comments for ListVoicesRequest ([#​244](https://togithub.com/googleapis/python-texttospeech/issues/244)) ([bc5b73f](https://togithub.com/googleapis/python-texttospeech/commit/bc5b73fbc62900f89a01486c6e8d42d459c34fd6)) ##### [2.9.1](https://www.github.com/googleapis/python-texttospeech/compare/v2.9.0...v2.9.1) (2022-01-08) ##### Documentation - Added virtualenv comment for clarity ([#​225](https://www.togithub.com/googleapis/python-texttospeech/issues/225)) ([61a7fce](https://www.github.com/googleapis/python-texttospeech/commit/61a7fcec0611712cdb1692b830db4aaca4d411b0)) - update comments for ListVoicesRequest ([#​229](https://www.togithub.com/googleapis/python-texttospeech/issues/229)) ([9ea340c](https://www.github.com/googleapis/python-texttospeech/commit/9ea340cee20298630a6a15bed0ed2df9f69b3d13))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/python-translate). Closes #278 --- .coveragerc | 2 ++ owlbot.py | 17 +++++------------ .../snippets/hybrid_glossaries/requirements.txt | 2 +- samples/snippets/requirements.txt | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.coveragerc b/.coveragerc index b08e5d0b..081506dd 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,6 +4,8 @@ branch = True [report] show_missing = True omit = + google/__init__.py + google/cloud/__init__.py google/cloud/translate/__init__.py exclude_lines = # Re-enable the standard pragma diff --git a/owlbot.py b/owlbot.py index d329fa9e..3fb13812 100644 --- a/owlbot.py +++ b/owlbot.py @@ -45,15 +45,11 @@ s.remove_staging_dirs() -# work around gapic generator bug -# https://github.com/googleapis/gapic-generator-python/pull/1071 -s.replace( - "google/cloud/**/types/*.py", - """\. - This field is a member of `oneof`_""", - """. - - This field is a member of `oneof`_""" +s.replace(".coveragerc", + """google/cloud/translate/__init__.py""", + """google/__init__.py + google/cloud/__init__.py + google/cloud/translate/__init__.py""", ) # ---------------------------------------------------------------------------- @@ -66,9 +62,6 @@ ) s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file -# Work around bug in templates https://github.com/googleapis/synthtool/pull/1335 -s.replace(".github/workflows/unittest.yml", "--fail-under=100", "--fail-under=99") - # ---------------------------------------------------------------------------- # Samples templates # ---------------------------------------------------------------------------- diff --git a/samples/snippets/hybrid_glossaries/requirements.txt b/samples/snippets/hybrid_glossaries/requirements.txt index 945d36de..c6718477 100644 --- a/samples/snippets/hybrid_glossaries/requirements.txt +++ b/samples/snippets/hybrid_glossaries/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 google-cloud-vision==2.6.3 -google-cloud-texttospeech==2.9.1 +google-cloud-texttospeech==2.10.0 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 0b3e1b5d..8c51bb99 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 -google-cloud-storage==2.0.0 +google-cloud-storage==2.1.0 google-cloud-automl==2.6.0 From 0860db20186a396c798dd68c9e50d748bb5bbe1a Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 24 Feb 2022 09:36:47 -0700 Subject: [PATCH 26/26] chore(main): release 3.7.0 (#315) --- .github/workflows/unittest.yml | 2 +- CHANGELOG.md | 13 +++++++++++++ owlbot.py | 6 ++++-- setup.py | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index e84424b8..074ee250 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -54,4 +54,4 @@ jobs: - name: Report coverage results run: | coverage combine .coverage-results/.coverage* - coverage report --show-missing --fail-under=99 + coverage report --show-missing --fail-under=100 diff --git a/CHANGELOG.md b/CHANGELOG.md index 02481558..887411b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ [1]: https://pypi.org/project/google-cloud-translate/#history +## [3.7.0](https://github.com/googleapis/python-translate/compare/v3.6.1...v3.7.0) (2022-02-03) + + +### Features + +* add api key support ([#329](https://github.com/googleapis/python-translate/issues/329)) ([4b08cd5](https://github.com/googleapis/python-translate/commit/4b08cd56ce230b843ced78a3f81c2e6511ac2a4f)) + + +### Bug Fixes + +* 290 added a create glossary line before each call using bistro-glossary ([#302](https://github.com/googleapis/python-translate/issues/302)) ([742e414](https://github.com/googleapis/python-translate/commit/742e414ad8ac83e4116c67740a42e264a63e3287)) +* resolve DuplicateCredentialArgs error when using credentials_file ([26791c2](https://github.com/googleapis/python-translate/commit/26791c251e851f921d23316e6ca5adab648c63c0)) + ### [3.6.1](https://www.github.com/googleapis/python-translate/compare/v3.6.0...v3.6.1) (2021-11-04) diff --git a/owlbot.py b/owlbot.py index 3fb13812..5114aaf7 100644 --- a/owlbot.py +++ b/owlbot.py @@ -46,8 +46,10 @@ s.remove_staging_dirs() s.replace(".coveragerc", - """google/cloud/translate/__init__.py""", - """google/__init__.py + """omit = + google/cloud/translate/__init__.py""", + """omit = + google/__init__.py google/cloud/__init__.py google/cloud/translate/__init__.py""", ) diff --git a/setup.py b/setup.py index 322ea30a..3c1e1432 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-translate" description = "Google Cloud Translation API client library" -version = "3.6.1" +version = "3.7.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'