From cbaf3624b79c7b7c229e41e226813601e7c28a6e Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Fri, 8 Oct 2021 12:30:37 -0700 Subject: [PATCH 1/4] fix: exception when grpc is disabled --- google/cloud/error_reporting/_logging.py | 4 ++-- tests/system/test_system.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/google/cloud/error_reporting/_logging.py b/google/cloud/error_reporting/_logging.py index 5e83d148..c7d1d909 100644 --- a/google/cloud/error_reporting/_logging.py +++ b/google/cloud/error_reporting/_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, diff --git a/tests/system/test_system.py b/tests/system/test_system.py index 28125c6a..44d78d56 100644 --- a/tests/system/test_system.py +++ b/tests/system/test_system.py @@ -15,6 +15,8 @@ import functools import operator import unittest +import os +import mock from google.cloud import error_reporting import google.cloud.errorreporting_v1beta1 @@ -112,6 +114,7 @@ def _get_error_count(class_name, client): class TestErrorReporting(unittest.TestCase): + def test_report_exception(self): # Get a class name unique to this test case. class_name = "RuntimeError" + unique_resource_id("_") @@ -127,3 +130,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() + From 22ee4b2bc426d0670d6bbf34993a16e036c2cf00 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 8 Oct 2021 19:34:11 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- tests/system/test_system.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/system/test_system.py b/tests/system/test_system.py index 44d78d56..176560a9 100644 --- a/tests/system/test_system.py +++ b/tests/system/test_system.py @@ -114,7 +114,6 @@ def _get_error_count(class_name, client): class TestErrorReporting(unittest.TestCase): - def test_report_exception(self): # Get a class name unique to this test case. class_name = "RuntimeError" + unique_resource_id("_") @@ -132,7 +131,7 @@ def test_report_exception(self): 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): + with mock.patch.dict( + "os.environ", {"GOOGLE_CLOUD_DISABLE_GRPC": "true"}, clear=True + ): self.test_report_exception() - From 739ae92fe2f9c52fc52fc762394bcece1208af5c Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Mon, 11 Oct 2021 10:28:51 -0700 Subject: [PATCH 3/4] fixed CI issues --- tests/system/test_system.py | 7 +++---- tests/unit/test__logging.py | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/system/test_system.py b/tests/system/test_system.py index 44d78d56..176560a9 100644 --- a/tests/system/test_system.py +++ b/tests/system/test_system.py @@ -114,7 +114,6 @@ def _get_error_count(class_name, client): class TestErrorReporting(unittest.TestCase): - def test_report_exception(self): # Get a class name unique to this test case. class_name = "RuntimeError" + unique_resource_id("_") @@ -132,7 +131,7 @@ def test_report_exception(self): 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): + with mock.patch.dict( + "os.environ", {"GOOGLE_CLOUD_DISABLE_GRPC": "true"}, clear=True + ): self.test_report_exception() - diff --git a/tests/unit/test__logging.py b/tests/unit/test__logging.py index 772b5229..c5b1cc32 100644 --- a/tests/unit/test__logging.py +++ b/tests/unit/test__logging.py @@ -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, From ac516225fc75009153492b67ceb1db4f4434ecb8 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Mon, 11 Oct 2021 10:32:41 -0700 Subject: [PATCH 4/4] removed unneeded import --- tests/system/test_system.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/test_system.py b/tests/system/test_system.py index 176560a9..4565a358 100644 --- a/tests/system/test_system.py +++ b/tests/system/test_system.py @@ -15,7 +15,6 @@ import functools import operator import unittest -import os import mock from google.cloud import error_reporting