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 ceac166 commit 7fadc14
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
20 changes: 11 additions & 9 deletions packages/google-cloud-translate/google/cloud/translate/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,27 @@ class Client(BaseClient):
: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."""

def __init__(self, target_language=ENGLISH_ISO_639,
credentials=None, http=None):
credentials=None, _http=None):
self.target_language = target_language
super(Client, self).__init__(credentials=credentials, http=http)
super(Client, self).__init__(credentials=credentials, _http=_http)
self._connection = Connection(self)

def get_languages(self, target_language=None):
Expand Down
26 changes: 13 additions & 13 deletions packages/google-cloud-translate/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_constructor(self):
from google.cloud.translate.client import ENGLISH_ISO_639

http = object()
client = self._make_one(http=http)
client = self._make_one(_http=http)
self.assertIsInstance(client._connection, Connection)
self.assertIsNone(client._connection.credentials)
self.assertIs(client._connection.http, http)
Expand All @@ -42,7 +42,7 @@ def test_constructor_non_default(self):

http = object()
target = 'es'
client = self._make_one(target_language=target, http=http)
client = self._make_one(target_language=target, _http=http)
self.assertIsInstance(client._connection, Connection)
self.assertIsNone(client._connection.credentials)
self.assertIs(client._connection.http, http)
Expand All @@ -51,7 +51,7 @@ def test_constructor_non_default(self):
def test_get_languages(self):
from google.cloud.translate.client import ENGLISH_ISO_639

client = self._make_one(http=object())
client = self._make_one(_http=object())
supported = [
{'language': 'en', 'name': 'English'},
{'language': 'af', 'name': 'Afrikaans'},
Expand All @@ -77,7 +77,7 @@ def test_get_languages(self):

def test_get_languages_no_target(self):
client = self._make_one(
target_language=None, http=object())
target_language=None, _http=object())
supported = [
{'language': 'en'},
{'language': 'af'},
Expand All @@ -102,7 +102,7 @@ def test_get_languages_no_target(self):
self.assertEqual(req['query_params'], {})

def test_get_languages_explicit_target(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
target_language = 'en'
supported = [
{'language': 'en', 'name': 'Spanish'},
Expand All @@ -128,7 +128,7 @@ def test_get_languages_explicit_target(self):
{'target': target_language})

def test_detect_language_bad_result(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value = 'takoy'
conn = client._connection = _Connection({})

Expand All @@ -146,7 +146,7 @@ def test_detect_language_bad_result(self):
self.assertEqual(req['query_params'], query_params)

def test_detect_language_single_value(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value = 'takoy'
detection = {
'confidence': 1.0,
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_detect_language_single_value(self):
self.assertEqual(req['query_params'], query_params)

def test_detect_language_multiple_values(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value1 = u'fa\xe7ade' # facade (with a cedilla)
detection1 = {
'confidence': 0.6166008,
Expand Down Expand Up @@ -215,7 +215,7 @@ def test_detect_language_multiple_values(self):
self.assertEqual(req['query_params'], query_params)

def test_detect_language_multiple_results(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value = 'soy'
detection1 = {
'confidence': 0.81496066,
Expand All @@ -240,7 +240,7 @@ def test_detect_language_multiple_results(self):
client.detect_language(value)

def test_translate_bad_result(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value = 'hvala ti'
conn = client._connection = _Connection({})

Expand All @@ -259,7 +259,7 @@ def test_translate_bad_result(self):
self.assertEqual(req['query_params'], query_params)

def test_translate_defaults(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value = 'hvala ti'
translation = {
'detectedSourceLanguage': 'hr',
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_translate_defaults(self):
self.assertEqual(req['query_params'], query_params)

def test_translate_multiple(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value1 = 'hvala ti'
translation1 = {
'detectedSourceLanguage': 'hr',
Expand Down Expand Up @@ -324,7 +324,7 @@ def test_translate_multiple(self):
self.assertEqual(req['query_params'], query_params)

def test_translate_explicit(self):
client = self._make_one(http=object())
client = self._make_one(_http=object())
value = 'thank you'
target_language = 'eo'
source_language = 'en'
Expand Down

0 comments on commit 7fadc14

Please sign in to comment.