diff --git a/logging/google/cloud/logging/_gax.py b/logging/google/cloud/logging/_gax.py index 7ddadba01d06..0ffd46dd3fcb 100644 --- a/logging/google/cloud/logging/_gax.py +++ b/logging/google/cloud/logging/_gax.py @@ -532,7 +532,7 @@ def make_gax_logging_api(client): :returns: A metrics API instance with the proper credentials. """ channel = make_secure_channel( - client._credentials, DEFAULT_USER_AGENT, + client._connection.credentials, DEFAULT_USER_AGENT, LoggingServiceV2Client.SERVICE_ADDRESS) generated = LoggingServiceV2Client(channel=channel) return _LoggingAPI(generated, client) @@ -548,7 +548,7 @@ def make_gax_metrics_api(client): :returns: A metrics API instance with the proper credentials. """ channel = make_secure_channel( - client._credentials, DEFAULT_USER_AGENT, + client._connection.credentials, DEFAULT_USER_AGENT, MetricsServiceV2Client.SERVICE_ADDRESS) generated = MetricsServiceV2Client(channel=channel) return _MetricsAPI(generated, client) @@ -564,7 +564,7 @@ def make_gax_sinks_api(client): :returns: A metrics API instance with the proper credentials. """ channel = make_secure_channel( - client._credentials, DEFAULT_USER_AGENT, + client._connection.credentials, DEFAULT_USER_AGENT, ConfigServiceV2Client.SERVICE_ADDRESS) generated = ConfigServiceV2Client(channel=channel) return _SinksAPI(generated, client) diff --git a/logging/google/cloud/logging/handlers/transports/background_thread.py b/logging/google/cloud/logging/handlers/transports/background_thread.py index 9c8ea85c937a..811bc23bdb9f 100644 --- a/logging/google/cloud/logging/handlers/transports/background_thread.py +++ b/logging/google/cloud/logging/handlers/transports/background_thread.py @@ -152,7 +152,7 @@ class BackgroundThreadTransport(Transport): def __init__(self, client, name): http = copy.deepcopy(client._http) self.client = client.__class__( - client.project, client._credentials, http) + client.project, client._connection.credentials, http) logger = self.client.logger(name) self.worker = _Worker(logger) diff --git a/logging/unit_tests/handlers/transports/test_background_thread.py b/logging/unit_tests/handlers/transports/test_background_thread.py index a21302f251d7..aa0cae2f2669 100644 --- a/logging/unit_tests/handlers/transports/test_background_thread.py +++ b/logging/unit_tests/handlers/transports/test_background_thread.py @@ -170,9 +170,13 @@ def batch(self): class _Client(object): def __init__(self, project, http=None, credentials=None): + import mock + self.project = project self._http = http self._credentials = credentials + self._connection = mock.Mock( + credentials=credentials, spec=['credentials']) def logger(self, name): # pylint: disable=unused-argument self._logger = _Logger(name) diff --git a/logging/unit_tests/test__gax.py b/logging/unit_tests/test__gax.py index e2f158ffd0cc..9020c44236e0 100644 --- a/logging/unit_tests/test__gax.py +++ b/logging/unit_tests/test__gax.py @@ -1085,7 +1085,8 @@ def test_it(self): from google.cloud.logging._gax import DEFAULT_USER_AGENT creds = object() - client = mock.Mock(_credentials=creds) + conn = mock.Mock(credentials=creds, spec=['credentials']) + client = mock.Mock(_connection=conn, spec=['_connection']) channels = [] channel_args = [] channel_obj = object() @@ -1130,7 +1131,8 @@ def test_it(self): from google.cloud.logging._gax import DEFAULT_USER_AGENT creds = object() - client = mock.Mock(_credentials=creds) + conn = mock.Mock(credentials=creds, spec=['credentials']) + client = mock.Mock(_connection=conn, spec=['_connection']) channels = [] channel_args = [] channel_obj = object() @@ -1175,7 +1177,8 @@ def test_it(self): from google.cloud.logging._gax import DEFAULT_USER_AGENT creds = object() - client = mock.Mock(_credentials=creds) + conn = mock.Mock(credentials=creds, spec=['credentials']) + client = mock.Mock(_connection=conn, spec=['_connection']) channels = [] channel_args = [] channel_obj = object()