Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exception when grpc is disabled #190

Merged
merged 5 commits into from Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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