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

GAPIC Header Consistency: Error Reporting #3055

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions error_reporting/google/cloud/error_reporting/_gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions error_reporting/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
29 changes: 26 additions & 3 deletions error_reporting/unit_tests/test__gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down