Skip to content

Commit

Permalink
Use ClientWithProject superclass for error reporting. (googleapis#3168)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer authored Mar 21, 2017
1 parent 3a8ba72 commit 536294c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 5 additions & 10 deletions error_reporting/google/cloud/error_reporting/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
except ImportError: # pragma: NO COVER
_HAVE_GAX = False

from google.cloud._helpers import _determine_default_project
from google.cloud.client import ClientWithProject
from google.cloud.error_reporting._logging import _ErrorReportingLoggingAPI
from google.cloud.environment_vars import DISABLE_GRPC

Expand Down Expand Up @@ -74,7 +74,7 @@ def __init__(self, method=None, url=None,
self.remoteIp = remote_ip


class Client(object):
class Client(ClientWithProject):
"""Error Reporting client. Currently Error Reporting is done by creating
a Logging client.
Expand Down Expand Up @@ -125,13 +125,8 @@ def __init__(self, project=None,
service=None,
version=None,
use_gax=None):
if project is None:
self._project = _determine_default_project()
else:
self._project = project
self._credentials = credentials
self._http = http

super(Client, self).__init__(project=project, credentials=credentials,
http=http)
self._report_errors_api = None

self.service = service if service else self.DEFAULT_SERVICE
Expand Down Expand Up @@ -162,7 +157,7 @@ def report_errors_api(self):
self._report_errors_api = make_report_error_api(self)
else:
self._report_errors_api = _ErrorReportingLoggingAPI(
self._project, self._credentials, self._http)
self.project, self._credentials, self._http)
return self._report_errors_api

def _build_error_report(self,
Expand Down
6 changes: 3 additions & 3 deletions error_reporting/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def _get_report_payload(self, error_api):
self.assertEqual(len(positional), 1)
return positional[0]

@mock.patch(
'google.cloud.error_reporting.client._determine_default_project')
@mock.patch('google.cloud.client._determine_default_project')
def test_ctor_default(self, default_mock):
credentials = _make_credentials()
default_mock.return_value = 'foo'
client = self._make_one(credentials=credentials)
self.assertEqual(client.service, client.DEFAULT_SERVICE)
self.assertEqual(client.version, None)
default_mock.assert_called_once_with()
default_mock.assert_called_once_with(None)

def test_ctor_params(self):
credentials = _make_credentials()
Expand Down

0 comments on commit 536294c

Please sign in to comment.