From 9f3c786590e448bfd734c95b0818c9e415fb0fab Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Thu, 30 Mar 2017 08:43:22 -0700 Subject: [PATCH] Renaming http argument(s) as _http. (#3235) --- .../google/cloud/language/client.py | 20 ++++++++++--------- .../tests/unit/test_client.py | 16 +++++++-------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/google-cloud-language/google/cloud/language/client.py b/packages/google-cloud-language/google/cloud/language/client.py index 55940063a641..39221316e428 100644 --- a/packages/google-cloud-language/google/cloud/language/client.py +++ b/packages/google-cloud-language/google/cloud/language/client.py @@ -28,24 +28,26 @@ class Client(client_module.Client): :type credentials: :class:`~google.auth.credentials.Credentials` :param credentials: (Optional) The OAuth2 Credentials to use for this - client. If not passed (and if no ``http`` object is + client. If not passed (and if no ``_http`` object is passed), falls back to the default inferred from the environment. - :type http: :class:`~httplib2.Http` - :param http: (Optional) HTTP object to make requests. Can be any object - that defines ``request()`` with the same interface as - :meth:`~httplib2.Http.request`. If not passed, an - ``http`` object is created that is bound to the - ``credentials`` for the current object. + :type _http: :class:`~httplib2.Http` + :param _http: (Optional) HTTP object to make requests. Can be any object + that defines ``request()`` with the same interface as + :meth:`~httplib2.Http.request`. If not passed, an + ``_http`` object is created that is bound to the + ``credentials`` for the current object. + This parameter should be considered private, and could + change in the future. """ SCOPE = ('https://www.googleapis.com/auth/cloud-platform',) """The scopes required for authenticating as an API consumer.""" - def __init__(self, credentials=None, http=None): + def __init__(self, credentials=None, _http=None): super(Client, self).__init__( - credentials=credentials, http=http) + credentials=credentials, _http=_http) self._connection = Connection(self) def document_from_text(self, content, **kwargs): diff --git a/packages/google-cloud-language/tests/unit/test_client.py b/packages/google-cloud-language/tests/unit/test_client.py index 87ad21655414..fe8684e75fe8 100644 --- a/packages/google-cloud-language/tests/unit/test_client.py +++ b/packages/google-cloud-language/tests/unit/test_client.py @@ -40,7 +40,7 @@ def test_ctor(self): creds = make_mock_credentials() http = object() - client = self._make_one(credentials=creds, http=http) + client = self._make_one(credentials=creds, _http=http) self.assertIsInstance(client._connection, Connection) self.assertIs(client._connection.credentials, creds) self.assertIs(client._connection.http, http) @@ -49,7 +49,7 @@ def test_document_from_text_factory(self): from google.cloud.language.document import Document creds = make_mock_credentials() - client = self._make_one(credentials=creds, http=object()) + client = self._make_one(credentials=creds, _http=object()) content = 'abc' language = 'es' @@ -64,7 +64,7 @@ def test_document_from_text_factory(self): def test_document_from_text_factory_failure(self): creds = make_mock_credentials() - client = self._make_one(credentials=creds, http=object()) + client = self._make_one(credentials=creds, _http=object()) with self.assertRaises(TypeError): client.document_from_text('abc', doc_type='foo') @@ -73,7 +73,7 @@ def test_document_from_html_factory(self): from google.cloud.language.document import Document creds = make_mock_credentials() - client = self._make_one(credentials=creds, http=object()) + client = self._make_one(credentials=creds, _http=object()) content = 'abc' language = 'ja' @@ -88,7 +88,7 @@ def test_document_from_html_factory(self): def test_document_from_html_factory_failure(self): creds = make_mock_credentials() - client = self._make_one(credentials=creds, http=object()) + client = self._make_one(credentials=creds, _http=object()) with self.assertRaises(TypeError): client.document_from_html('abc', doc_type='foo') @@ -97,7 +97,7 @@ def test_document_from_gcs_url_factory(self): from google.cloud.language.document import Document creds = make_mock_credentials() - client = self._make_one(credentials=creds, http=object()) + client = self._make_one(credentials=creds, _http=object()) gcs_url = 'gs://my-text-bucket/sentiment-me.txt' document = client.document_from_gcs_url(gcs_url) @@ -112,7 +112,7 @@ def test_document_from_gcs_url_factory_explicit(self): from google.cloud.language.document import Encoding creds = make_mock_credentials() - client = self._make_one(credentials=creds, http=object()) + client = self._make_one(credentials=creds, _http=object()) encoding = Encoding.UTF32 gcs_url = 'gs://my-text-bucket/sentiment-me.txt' @@ -130,7 +130,7 @@ def test_document_from_url_deprecation(self): import warnings creds = make_mock_credentials() - client = self._make_one(credentials=creds, http=object()) + client = self._make_one(credentials=creds, _http=object()) Client = self._get_target_class() with mock.patch.object(Client, 'document_from_gcs_url') as dfgu: