Skip to content

Commit

Permalink
GAPIC Header Consistency: Error Reporting (googleapis#3055)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer authored Feb 23, 2017
1 parent 74dd575 commit cd101b2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
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

0 comments on commit cd101b2

Please sign in to comment.