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

Use ClientWithProject superclass for error reporting. #3168

Merged
merged 3 commits into from
Mar 21, 2017
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
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)

This comment was marked as spam.

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