Skip to content

Commit

Permalink
Renaming http argument(s) as _http. (#3235)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes authored and lukesneeringer committed Mar 30, 2017
1 parent a995d9d commit 9f3c786
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
20 changes: 11 additions & 9 deletions packages/google-cloud-language/google/cloud/language/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 8 additions & 8 deletions packages/google-cloud-language/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'
Expand All @@ -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')
Expand All @@ -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 = '<html>abc</html>'
language = 'ja'
Expand All @@ -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')
Expand All @@ -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)
Expand All @@ -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'
Expand All @@ -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:
Expand Down

0 comments on commit 9f3c786

Please sign in to comment.