Skip to content

Commit cb6e0be

Browse files
committed
Changing resource manager Connection to only accept client.
1 parent c91fa4a commit cb6e0be

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

resource_manager/google/cloud/resource_manager/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
from google.cloud.resource_manager.project import Project
2121

2222

23-
SCOPE = Connection.SCOPE
23+
SCOPE = Client.SCOPE

resource_manager/google/cloud/resource_manager/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ class Client(BaseClient):
4747
``credentials`` for the current object.
4848
"""
4949

50+
SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
51+
"""The scopes required for authenticating as a Resouce Manager consumer."""
52+
5053
def __init__(self, credentials=None, http=None):
5154
super(Client, self).__init__(
5255
credentials=credentials, http=http)
53-
self._connection = Connection(
54-
credentials=self._credentials, http=self._http)
56+
self._connection = Connection(self)
5557

5658
def new_project(self, project_id, name=None, labels=None):
5759
"""Create a project bound to the current client.

resource_manager/google/cloud/resource_manager/connection.py

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

3838
API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'
3939
"""A template for the URL of a particular API call."""
40-
41-
SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
42-
"""The scopes required for authenticating as a Resouce Manager consumer."""

resource_manager/unit_tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def test_constructor(self):
4141
credentials = _make_credentials()
4242
client = self._make_one(credentials=credentials, http=http)
4343
self.assertIsInstance(client._connection, Connection)
44-
self.assertEqual(client._connection._credentials, credentials)
45-
self.assertEqual(client._connection._http, http)
44+
self.assertIs(client._credentials, credentials)
45+
self.assertIs(client._http_internal, http)
4646

4747
def test_new_project_factory(self):
4848
from google.cloud.resource_manager.project import Project

resource_manager/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
conn.API_VERSION,
@@ -39,7 +39,7 @@ def test_build_api_url_w_extra_query_params(self):
3939
from six.moves.urllib.parse import parse_qsl
4040
from six.moves.urllib.parse import urlsplit
4141

42-
conn = self._make_one()
42+
conn = self._make_one(object())
4343
uri = conn.build_api_url('/foo', {'bar': 'baz'})
4444
scheme, netloc, path, qs, _ = urlsplit(uri)
4545
self.assertEqual('%s://%s' % (scheme, netloc), conn.API_BASE_URL)

0 commit comments

Comments
 (0)