8000 chore: use gapic-generator-python 0.62.1 (#246) · googleapis/google-cloud-python@9c10310 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c10310

Browse files
chore: use gapic-generator-python 0.62.1 (#246)
- [ ] Regenerate this pull request now. fix: resolve DuplicateCredentialArgs error when using credentials_file committer: parthea PiperOrigin-RevId: 425964861 Source-Link: googleapis/googleapis@84b1a5a Source-Link: googleapis/googleapis-gen@4fb761b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9
1 parent f216163 commit 9c10310

File tree

10 files changed

+176
-18
lines changed

10 files changed

+176
-18
lines changed

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/async_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async def list_voices(
237237
238238
"""
239239
# Create or coerce a protobuf request object.
240-
# Sanity check: If we got a request object, we should *not* have
240+
# Quick check: If we got a request object, we should *not* have
241241
# gotten any keyword arguments that map to the request.
242242
has_flattened_params = any([language_code])
243243
if request is not None and has_flattened_params:
@@ -319,7 +319,7 @@ async def synthesize_speech(
319319
320320
"""
321321
# Create or coerce a protobuf request object.
322-
# Sanity check: If we got a request object, we should *not* have
322+
# Quick check: If we got a request object, we should *not* have
323323
# gotten any keyword arguments that map to the request.
324324
has_flattened_params = any([input, voice, audio_config])
325325
if request is not None and has_flattened_params:

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def list_voices(
422422
423423
"""
424424
# Create or coerce a protobuf request object.
425-
# Sanity check: If we got a request object, we should *not* have
425+
# Quick check: If we got a request object, we should *not* have
426426
# gotten any keyword arguments that map to the request.
427427
has_flattened_params = any([language_code])
428428
if request is not None and has_flattened_params:
@@ -504,7 +504,7 @@ def synthesize_speech(
504504
505505
"""
506506
# Create or coerce a protobuf request object.
507-
# Sanity check: If we got a request object, we should *not* have
507+
# Quick check: If we got a request object, we should *not* have
508508
# gotten any keyword arguments that map to the request.
509509
has_flattened_params = any([input, voice, audio_config])
510510
if request is not None and has_flattened_params:

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@ def __init__(
158158
if not self._grpc_channel:
159159
self._grpc_channel = type(self).create_channel(
160160
self._host,
161+
# use the credentials which are saved
161162
credentials=self._credentials,
162-
credentials_file=credentials_file,
163+
# Set ``credentials_file`` to ``None`` here as
164+
# the credentials that we saved earlier should be used.
165+
credentials_file=None,
163166
scopes=self._scopes,
164167
ssl_credentials=self._ssl_channel_credentials,
165168
quota_project_id=quota_project_id,

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1/services/text_to_speech/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ def __init__(
203203
if not self._grpc_channel:
204204
self._grpc_channel = type(self).create_channel(
205205
self._host,
206+
# use the credentials which are saved
206207
credentials=self._credentials,
207-
credentials_file=credentials_file,
208+
# Set ``credentials_file`` to ``None`` here as
209+
# the credentials that we saved earlier should be used.
210+
credentials_file=None,
208211
scopes=self._scopes,
209212
ssl_credentials=self._ssl_channel_credentials,
210213
quota_project_id=quota_project_id,

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/async_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ async def list_voices(
239239
240240
"""
241241
# Create or coerce a protobuf request object.
242-
# Sanity check: If we got a request object, we should *not* have
242+
# Quick check: If we got a request object, we should *not* have
243243
# gotten any keyword arguments that map to the request.
244244
has_flattened_params = any([language_code])
245245
if request is not None and has_flattened_params:
@@ -321,7 +321,7 @@ async def synthesize_speech(
321321
322322
"""
323323
# Create or coerce a protobuf request object.
324-
# Sanity check: If we got a request object, we should *not* have
324+
# Quick check: If we got a request object, we should *not* have
325325
# gotten any keyword arguments that map to the request.
326326
has_flattened_params = any([input, voice, audio_config])
327327
if request is not None and has_flattened_params:

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def list_voices(
438438
439439
"""
440440
# Create or coerce a protobuf request object.
441-
# Sanity check: If we got a request object, we should *not* have
441+
# Quick check: If we got a request object, we should *not* have
442442
# gotten any keyword arguments that map to the request.
443443
has_flattened_params = any([language_code])
444444
if request is not None and has_flattened_params:
@@ -520,7 +520,7 @@ def synthesize_speech(
520520
521521
"""
522522
# Create or coerce a protobuf request object.
523-
# Sanity check: If we got a request object, we should *not* have
523+
# Quick check: If we got a request object, we should *not* have
524524
# gotten any keyword arguments that map to the request.
525525
has_flattened_params = any([input, voice, audio_config])
526526
if request is not None and has_flattened_params:

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@ def __init__(
158158
if not self._grpc_channel:
159159
self._grpc_channel = type(self).create_channel(
160160
self._host,
161+
# use the credentials which are saved
161162
credentials=self._credentials,
162-
credentials_file=credentials_file,
163+
# Set ``credentials_file`` to ``None`` here as
164+
# the credentials that we saved earlier should be used.
165+
credentials_file=None,
163166
scopes=self._scopes,
164167
ssl_credentials=self._ssl_channel_credentials,
165168
quota_project_id=quota_project_id,

packages/google-cloud-texttospeech/google/cloud/texttospeech_v1beta1/services/text_to_speech/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ def __init__(
203203
if not self._grpc_channel:
204204
self._grpc_channel = type(self).create_channel(
205205
self._host,
206+
# use the credentials which are saved
206207
credentials=self._credentials,
207-
credentials_file=credentials_file,
208+
# Set ``credentials_file`` to ``None`` here as
209+
# the credentials that we saved earlier should be used.
210+
credentials_file=None,
208211
scopes=self._scopes,
209212
ssl_credentials=self._ssl_channel_credentials,
210213
quota_project_id=quota_project_id,

packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1/test_text_to_speech.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,21 +492,28 @@ def test_text_to_speech_client_client_options_scopes(
492492

493493

494494
@pytest.mark.parametrize(
495-
"client_class,transport_class,transport_name",
495+
"client_class,transport_class,transport_name,grpc_helpers",
496496
[
497-
(TextToSpeechClient, transports.TextToSpeechGrpcTransport, "grpc"),
497+
(
498+
TextToSpeechClient,
499+
transports.TextToSpeechGrpcTransport,
500+
"grpc",
501+
grpc_helpers,
502+
),
498503
(
499504
TextToSpeechAsyncClient,
500505
transports.TextToSpeechGrpcAsyncIOTransport,
501506
"grpc_asyncio",
507+
grpc_helpers_async,
502508
),
503509
],
504510
)
505511
def test_text_to_speech_client_client_options_credentials_file(
506-
client_class, transport_class, transport_name
512+
client_class, transport_class, transport_name, grpc_helpers
507513
):
508514
# Check the case credentials file is provided.
509515
options = client_options.ClientOptions(credentials_file="credentials.json")
516+
510517
with mock.patch.object(transport_class, "__init__") as patched:
511518
patched.return_value = None
512519
client = client_class(client_options=options, transport=transport_name)
@@ -540,6 +547,72 @@ def test_text_to_speech_client_client_options_from_dict():
540547
)
541548

542549

550+
@pytest.mark.parametrize(
551+
"client_class,transport_class,transport_name,grpc_helpers",
552+
[
553+
(
554+
TextToSpeechClient,
555+
transports.TextToSpeechGrpcTransport,
556+
"grpc",
557+
grpc_helpers,
558+
),
559+
(
560+
TextToSpeechAsyncClient,
561+
transports.TextToSpeechGrpcAsyncIOTransport,
562+
"grpc_asyncio",
563+
grpc_helpers_async,
564+
),
565+
],
566+
)
567+
def test_text_to_speech_client_create_channel_credentials_file(
568+
client_class, transport_class, transport_name, grpc_helpers
569+
):
570+
# Check the case credentials file is provided.
571+
options = client_options.ClientOptions(credentials_file="credentials.json")
572+
573+
with mock.patch.object(transport_class, "__init__") as patched:
574+
patched.return_value = None
575+
client = client_class(client_options=options, transport=transport_name)
576+
patched.assert_called_once_with(
577+
credentials=None,
578+
credentials_file="credentials.json",
579+
host=client.DEFAULT_ENDPOINT,
580+
scopes=None,
581+
client_cert_source_for_mtls=None,
582+
quota_project_id=None,
583+
client_info=transports.base.DEFAULT_CLIENT_INFO,
584+
always_use_jwt_access=True,
585+
)
586+
587+
# test that the credentials from file are saved and used as the credentials.
588+
with mock.patch.object(
589+
google.auth, "load_credentials_from_file", autospec=True
590+
) as load_creds, mock.patch.object(
591+
google.auth, "default", autospec=True
592+
) as adc, mock.patch.object(
593+
grpc_helpers, "create_channel"
594+
) as create_channel:
595+
creds = ga_credentials.AnonymousCredentials()
596+
file_creds = ga_credentials.AnonymousCredentials()
597+
load_creds.return_value = (file_creds, None)
598+
adc.return_value = (creds, None)
599+
client = client_class(client_options=options, transport=transport_name)
600+
create_channel.assert_called_with(
601+
"texttospeech.googleapis.com:443",
602+
credentials=file_creds,
603+
credentials_file=None,
604+
quota_project_id=None,
605+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
606+
scopes=None,
607+
default_host="texttospeech.googleapis.com",
608+
ssl_credentials=None,
609+
options=[
610+
("grpc.max_send_message_length", -1),
611+
("grpc.max_receive_message_length", -1),
612+
],
613+
)
614+
615+
543616
@pytest.mark.parametrize("request_type", [cloud_tts.ListVoicesRequest, dict,])
544617
def test_list_voices(request_type, transport: str = "grpc"):
545618
client = TextToSpeechClient(

packages/google-cloud-texttospeech/tests/unit/gapic/texttospeech_v1beta1/test_text_to_speech.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,21 +494,28 @@ def test_text_to_speech_client_client_options_scopes(
494494

495495

496496
@pytest.mark.parametrize(
497-
"client_class,transport_class,transport_name",
497+
"client_class,transport_class,transport_name,grpc_helpers",
498498
[
499-
(TextToSpeechClient, transports.TextToSpeechGrpcTransport, "grpc"),
499+
(
500+
TextToSpeechClient,
501+
transports.TextToSpeechGrpcTransport,
502+
"grpc",
503+
grpc_helpers,
504+
),
500505
(
501506
TextToSpeechAsyncClient,
502507
transports.TextToSpeechGrpcAsyncIOTransport,
503508
"grpc_asyncio",
509+
grpc_helpers_async,
504510
),
505511
],
506512
)
507513
def test_text_to_speech_client_client_options_credentials_file(
508-
client_class, transport_class, transport_name
514+
client_class, transport_class, transport_name, grpc_helpers
509515
):
510516
# Check the case credentials file is provided.
511517
options = client_options.ClientOptions(credentials_file="credentials.json")
518+
512519
with mock.patch.object(transport_class, "__init__") as patched:
513520
patched.return_value = None
514521
client = client_class(client_options=options, transport=transport_name)
@@ -542,6 +549,72 @@ def test_text_to_speech_client_client_options_from_dict():
542549
)
543550

544551

552+
@pytest.mark.parametrize(
553+
"client_class,transport_class,transport_name,grpc_helpers",
554+
[
555+
(
556+
TextToSpeechClient,
557+
transports.TextToSpeechGrpcTransport,
558+
"grpc",
559+
grpc_helpers,
560+
),
561+
(
562+
TextToSpeechAsyncClient,
563+
transports.TextToSpeechGrpcAsyncIOTransport,
564+
"grpc_asyncio",
565+
grpc_helpers_async,
566+
),
567+
],
568+
)
569+
def test_text_to_speech_client_create_channel_credentials_file(
570+
client_class, transport_class, transport_name, grpc_helpers
571+
):
572+
# Check the case credentials file is provided.
573+
options = client_options.ClientOptions(credentials_file="credentials.json")
574+
575+
with mock.patch.object(transport_class, "__init__") as patched:
576+
patched.return_value = None
577+
client = client_class(client_options=options, transport=transport_name)
578+
patched.assert_called_once_with(
579+
credentials=None,
580+
credentials_file="credentials.json",
581+
host=client.DEFAULT_ENDPOINT,
582+
scopes=None,
583+
client_cert_source_for_mtls=None,
584+
quota_project_id=None,
585+
client_info=transports.base.DEFAULT_CLIENT_INFO,
586+
always_use_jwt_access=True,
587+
)
588+
589+
# test that the credentials from file are saved and used as the credentials.
590+
with mock.patch.object(
591+
google.auth, "load_credentials_from_file", autospec=True
592+
) as load_creds, mock.patch.object(
593+
google.auth, "default", autospec=True
594+
) as adc, mock.patch.object(
595+
grpc_helpers, "create_channel"
596+
) as create_channel:
597+
creds = ga_credentials.AnonymousCredentials()
598+
file_creds = ga_credentials.AnonymousCredentials()
599+
load_creds.return_value = (file_creds, None)
600+
adc.return_value = (creds, None)
601+
client = client_class(client_options=options, transport=transport_name)
602+
create_channel.assert_called_with(
603+
"texttospeech.googleapis.com:443",
604+
credentials=file_creds,
605+
credentials_file=None,
606+
quota_project_id=None,
607+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
608+
scopes=None,
609+
default_host="texttospeech.googleapis.com",
610+
ssl_credentials=None,
611+
options=[
612+
("grpc.max_send_message_length", -1),
613+
("grpc.max_receive_message_length", -1),
614+
],
615+
)
616+
617+
545618
@pytest.mark.parametrize("request_type", [cloud_tts.ListVoicesRequest, dict,])
546619
def test_list_voices(request_type, transport: str = "grpc"):
547620
client = TextToSpeechClient(

0 commit comments

Comments
 (0)
0