Skip to content

Commit

Permalink
fix: exception thrown when grpc is disabled (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Oct 11, 2021
1 parent 0611b2f commit 929e293
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions google/cloud/error_reporting/_logging.py
Expand Up @@ -70,8 +70,8 @@ def __init__(
client_options=None,
):
self.logging_client = google.cloud.logging.Client(
project,
credentials,
project=project,
credentials=credentials,
_http=_http,
client_info=client_info,
client_options=client_options,
Expand Down
7 changes: 7 additions & 0 deletions tests/system/test_system.py
Expand Up @@ -15,6 +15,7 @@
import functools
import operator
import unittest
import mock

from google.cloud import error_reporting
import google.cloud.errorreporting_v1beta1
Expand Down Expand Up @@ -127,3 +128,9 @@ def test_report_exception(self):

error_count = wrapped_get_count(class_name, Config.CLIENT)
self.assertEqual(error_count, 1)

def test_report_exception_no_grpc(self):
with mock.patch.dict(
"os.environ", {"GOOGLE_CLOUD_DISABLE_GRPC": "true"}, clear=True
):
self.test_report_exception()
10 changes: 7 additions & 3 deletions tests/unit/test__logging.py
Expand Up @@ -40,7 +40,11 @@ def test_ctor_defaults(self, mocked_cls):

self.assertIs(logging_api.logging_client, mocked_cls.return_value)
mocked_cls.assert_called_once_with(
self.PROJECT, credentials, _http=None, client_info=None, client_options=None
project=self.PROJECT,
credentials=credentials,
_http=None,
client_info=None,
client_options=None,
)

@mock.patch("google.cloud.logging.Client")
Expand All @@ -60,8 +64,8 @@ def test_ctor_explicit(self, mocked_cls):

self.assertIs(logging_api.logging_client, mocked_cls.return_value)
mocked_cls.assert_called_once_with(
self.PROJECT,
credentials,
project=self.PROJECT,
credentials=credentials,
_http=http,
client_info=client_info,
client_options=client_options,
Expand Down

0 comments on commit 929e293

Please sign in to comment.