Skip to content
Permalink
Browse files
fix: exception thrown when grpc is disabled (#190)
  • Loading branch information
daniel-sanche committed Oct 11, 2021
1 parent 0611b2f commit 929e293a479dea3059bfca152b93d7740348fc39
Showing with 16 additions and 5 deletions.
  1. +2 −2 google/cloud/error_reporting/_logging.py
  2. +7 −0 tests/system/test_system.py
  3. +7 −3 tests/unit/test__logging.py
@@ -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,
@@ -15,6 +15,7 @@
import functools
import operator
import unittest
import mock

from google.cloud import error_reporting
import google.cloud.errorreporting_v1beta1
@@ -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()
@@ -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")
@@ -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,

0 comments on commit 929e293

Please sign in to comment.