def test_make_report_error_api(self): from google.cloud.errorreporting_v1beta1.gapic import ( report_errors_service_client) from google.cloud.error_reporting._gapic import make_report_error_api client = mock.Mock( _credentials=mock.sentinel.credentials, project='prahj-ekt', spec=['project', '_credentials'], ) # 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.assertEqual(kwargs['credentials'], mock.sentinel.credentials) self.assertIsNotNone(kwargs['client_info']) # Assert that the final error client has the project in # the expected location. self.assertIs(report_error_client._project, client.project)
def report_errors_api(self): """Helper for logging-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs :rtype: :class:`_gapic._ErrorReportingGapicApi` or :class:`._logging._ErrorReportingLoggingAPI` :returns: A class that implements the report errors API. """ if self._report_errors_api is None: if self._use_grpc: self._report_errors_api = make_report_error_api(self) else: self._report_errors_api = _ErrorReportingLoggingAPI( self.project, self._credentials, self._http, self._client_info, self._client_options, ) return self._report_errors_api
def report_errors_api(self): """Helper for logging-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs :rtype: :class:`_gapic._ErrorReportingGapicApi` or :class:`._logging._ErrorReportingLoggingAPI` :returns: A class that implements the report errors API. """ if self._report_errors_api is None: if self._use_grpc: self._report_errors_api = make_report_error_api(self) else: self._report_errors_api = _ErrorReportingLoggingAPI( self.project, self._credentials, self._http) return self._report_errors_api
def _call_fut(client): from google.cloud.error_reporting._gapic import make_report_error_api return make_report_error_api(client)