Skip to content

Commit 683ce71

Browse files
committed
Changing translate Connection to only accept client.
1 parent d961233 commit 683ce71

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

translate/google/cloud/translate/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ class Client(BaseClient):
5454
``credentials`` for the current object.
5555
"""
5656

57+
SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
58+
"""The scopes required for authenticating."""
59+
5760
def __init__(self, target_language=ENGLISH_ISO_639,
5861
credentials=None, http=None):
5962
self.target_language = target_language
6063
super(Client, self).__init__(credentials=credentials, http=http)
61-
self._connection = Connection(
62-
credentials=self._credentials, http=self._http)
64+
self._connection = Connection(self)
6365

6466
def get_languages(self, target_language=None):
6567
"""Get list of supported languages for translation.

translate/google/cloud/translate/connection.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,3 @@ class Connection(_http.JSONConnection):
2828

2929
API_URL_TEMPLATE = '{api_base_url}/language/translate/{api_version}{path}'
3030
"""A template for the URL of a particular API call."""
31-
32-
SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
33-
"""The scopes required for authenticating."""

translate/unit_tests/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _make_one(self, *args, **kw):
2727
return self._get_target_class()(*args, **kw)
2828

2929
def test_build_api_url_no_extra_query_params(self):
30-
conn = self._make_one()
30+
conn = self._make_one(object())
3131
URI = '/'.join([
3232
conn.API_BASE_URL,
3333
'language',
@@ -41,7 +41,7 @@ def test_build_api_url_w_extra_query_params(self):
4141
from six.moves.urllib.parse import parse_qsl
4242
from six.moves.urllib.parse import urlsplit
4343

44-
conn = self._make_one()
44+
conn = self._make_one(object())
4545
query_params = [('q', 'val1'), ('q', 'val2')]
4646
uri = conn.build_api_url('/foo', query_params=query_params)
4747
scheme, netloc, path, qs, _ = urlsplit(uri)

0 commit comments

Comments
 (0)