FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: use gapic-generator-python 0.62.1 (#185) · googleapis/google-cloud-python@8618ef5 · GitHub

Commit 8618ef5

Browse files
chore: use gapic-generator-python 0.62.1 (#185)
- [ ] 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 132afa1 commit 8618ef5

5 files changed

Lines changed: 89 additions & 7 deletions

File tree

‎packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ async def get_metadata(
467467
468468
"""
469469
# Create or coerce a protobuf request object.
470-
# Sanity check: If we got a request object, we should *not* have
470+
# Quick check: If we got a request object, we should *not* have
471471
# gotten any keyword arguments that map to the request.
472472
has_flattened_params = any([name])
473473
if request is not None and has_flattened_params:

‎packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def get_metadata(
665665
666666
"""
667667
# Create or coerce a protobuf request object.
668-
# Sanity check: If we got a request object, we should *not* have
668+
# Quick check: If we got a request object, we should *not* have
669669
# gotten any keyword arguments that map to the request.
670670
has_flattened_params = any([name])
671671
if request is not None and has_flattened_params:

‎packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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-analytics-data/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py‎

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,21 +523,28 @@ def test_beta_analytics_data_client_client_options_scopes(
523523

524524

525525
@pytest.mark.parametrize(
526-
"client_class,transport_class,transport_name",
526+
"client_class,transport_class,transport_name,grpc_helpers",
527527
[
528-
(BetaAnalyticsDataClient, transports.BetaAnalyticsDataGrpcTransport, "grpc"),
528+
(
529+
BetaAnalyticsDataClient,
530+
transports.BetaAnalyticsDataGrpcTransport,
531+
"grpc",
532+
grpc_helpers,
533+
),
529534
(
530535
BetaAnalyticsDataAsyncClient,
531536
transports.BetaAnalyticsDataGrpcAsyncIOTransport,
532537
"grpc_asyncio",
538+
grpc_helpers_async,
533539
),
534540
],
535541
)
536542
def test_beta_analytics_data_client_client_options_credentials_file(
537-
client_class, transport_class, transport_name
543+
client_class, transport_class, transport_name, grpc_helpers
538544
):
539545
# Check the case credentials file is provided.
540546
options = client_options.ClientOptions(credentials_file="credentials.json")
547+
541548
with mock.patch.object(transport_class, "__init__") as patched:
542549
patched.return_value = None
543550
client = client_class(client_options=options, transport=transport_name)
@@ -573,6 +580,75 @@ def test_beta_analytics_data_client_client_options_from_dict():
573580
)
574581

575582

583+
@pytest.mark.parametrize(
584+
"client_class,transport_class,transport_name,grpc_helpers",
585+
[
586+
(
587+
BetaAnalyticsDataClient,
588+
transports.BetaAnalyticsDataGrpcTransport,
589+
"grpc",
590+
grpc_helpers,
591+
),
592+
(
593+
BetaAnalyticsDataAsyncClient,
594+
transports.BetaAnalyticsDataGrpcAsyncIOTransport,
595+
"grpc_asyncio",
596+
grpc_helpers_async,
597+
),
598+
],
599+
)
600+
def test_beta_analytics_data_client_create_channel_credentials_file(
601+
client_class, transport_class, transport_name, grpc_helpers
602+
):
603+
# Check the case credentials file is provided.
604+
options = client_options.ClientOptions(credentials_file="credentials.json")
605+
606+
with mock.patch.object(transport_class, "__init__") as patched:
607+
patched.return_value = None
608+
client = client_class(client_options=options, transport=transport_name)
609+
patched.assert_called_once_with(
610+
credentials=None,
611+
credentials_file="credentials.json",
612+
host=client.DEFAULT_ENDPOINT,
613+
scopes=None,
614+
client_cert_source_for_mtls=None,
615+
quota_project_id=None,
616+
client_info=transports.base.DEFAULT_CLIENT_INFO,
617+
always_use_jwt_access=True,
618+
)
619+
620+
# test that the credentials from file are saved and used as the credentials.
621+
with mock.patch.object(
622+
google.auth, "load_credentials_from_file", autospec=True
623+
) as load_creds, mock.patch.object(
624+
google.auth, "default", autospec=True
625+
) as adc, mock.patch.object(
626+
grpc_helpers, "create_channel"
627+
) as create_channel:
628+
creds = ga_credentials.AnonymousCredentials()
629+
file_creds = ga_credentials.AnonymousCredentials()
630+
load_creds.return_value = (file_creds, None)
631+
adc.return_value = (creds, None)
632+
client = client_class(client_options=options, transport=transport_name)
633+
create_channel.assert_called_with(
634+
"analyticsdata.googleapis.com:443",
635+
credentials=file_creds,
636+
credentials_file=None,
637+
quota_project_id=None,
638+
default_scopes=(
639+
"https://www.googleapis.com/auth/analytics",
640+
"https://www.googleapis.com/auth/analytics.readonly",
641+
),
642+
scopes=None,
643+
default_host="analyticsdata.googleapis.com",
644+
ssl_credentials=None,
645+
options=[
646+
("grpc.max_send_message_length", -1),
647+
("grpc.max_receive_message_length", -1),
648+
],
649+
)
650+
651+
576652
@pytest.mark.parametrize("request_type", [analytics_data_api.RunReportRequest, dict,])
577653
def test_run_report(request_type, transport: str = "grpc"):
578654
client = BetaAnalyticsDataClient(

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL