diff --git a/error_reporting/google/cloud/error_reporting/_gax.py b/error_reporting/google/cloud/error_reporting/_gax.py index e480fcf7380a..a5a58995135f 100644 --- a/error_reporting/google/cloud/error_reporting/_gax.py +++ b/error_reporting/google/cloud/error_reporting/_gax.py @@ -19,10 +19,12 @@ from google.cloud.gapic.errorreporting.v1beta1 import ( report_errors_service_client) -from google.cloud.grpc.devtools.clouderrorreporting.v1beta1 import ( +from google.cloud.proto.devtools.clouderrorreporting.v1beta1 import ( report_errors_service_pb2) from google.protobuf.json_format import ParseDict +from google.cloud.error_reporting import __version__ + def make_report_error_api(client): """Create an instance of the GAX Logging API. @@ -38,7 +40,7 @@ def make_report_error_api(client): DEFAULT_USER_AGENT, report_errors_service_client.ReportErrorsServiceClient.SERVICE_ADDRESS) gax_client = report_errors_service_client.ReportErrorsServiceClient( - channel=channel) + channel=channel, lib_name='gccl', lib_version=__version__) return _ErrorReportingGaxApi(gax_client, client.project) diff --git a/error_reporting/setup.py b/error_reporting/setup.py index 199237bbc4ce..6412170fb368 100644 --- a/error_reporting/setup.py +++ b/error_reporting/setup.py @@ -51,13 +51,13 @@ REQUIREMENTS = [ 'google-cloud-core >= 0.23.0, < 0.24dev', - 'google-cloud-logging >= 0.22.0, < 0.23dev', - 'gapic-google-cloud-error-reporting-v1beta1 >= 0.14.0, < 0.15dev' + 'google-cloud-logging >= 0.23.0, < 0.24dev', + 'gapic-google-cloud-error-reporting-v1beta1 >= 0.15.0, < 0.16dev' ] setup( name='google-cloud-error-reporting', - version='0.22.0', + version='0.23.0', description='Python Client for Stackdriver Error Reporting', long_description=README, namespace_packages=[ diff --git a/error_reporting/unit_tests/test__gax.py b/error_reporting/unit_tests/test__gax.py index 4eada07c79bf..b5345045ca8b 100644 --- a/error_reporting/unit_tests/test__gax.py +++ b/error_reporting/unit_tests/test__gax.py @@ -20,12 +20,35 @@ class Test_make_report_error_api(unittest.TestCase): def test_make_report_error_api(self): + from google.cloud.gapic.errorreporting.v1beta1 import ( + report_errors_service_client) + + from grpc._channel import Channel + + from google.cloud.error_reporting import __version__ from google.cloud.error_reporting._gax import make_report_error_api client = mock.Mock() - client.project = mock.Mock() - report_error_client = make_report_error_api(client) - self.assertEqual(report_error_client._project, client.project) + + # Mock out the constructor for the GAPIC client. + ServiceClient = report_errors_service_client.ReportErrorsServiceClient + with mock.patch.object(ServiceClient, '__init__') as resc: + resc.return_value = None + + # Call the function being tested. + report_error_client = make_report_error_api(client) + + # Assert that the arguments to the GAPIC constructor appear + # to be correct. + resc.assert_called_once() + _, _, kwargs = resc.mock_calls[0] + self.assertIsInstance(kwargs['channel'], Channel) + self.assertEqual(kwargs['lib_name'], 'gccl') + self.assertEqual(kwargs['lib_version'], __version__) + + # Assert that the final error client has the project in + # the expected location. + self.assertIs(report_error_client._project, client.project) class Test_ErrorReportingGaxApi(unittest.TestCase):