Skip to content

Commit

Permalink
Changing resource manager Connection to only accept client.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Jan 27, 2017
1 parent e2ce1fc commit ec85966
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
from google.cloud.resource_manager.project import Project


SCOPE = Connection.SCOPE
SCOPE = Client.SCOPE
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ class Client(BaseClient):
``credentials`` for the current object.
"""

SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
"""The scopes required for authenticating as a Resouce Manager consumer."""

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

def new_project(self, project_id, name=None, labels=None):
"""Create a project bound to the current client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,3 @@ class Connection(_http.JSONConnection):

API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'
"""A template for the URL of a particular API call."""

SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
"""The scopes required for authenticating as a Resouce Manager consumer."""
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def test_constructor(self):
credentials = _make_credentials()
client = self._make_one(credentials=credentials, http=http)
self.assertIsInstance(client._connection, Connection)
self.assertEqual(client._connection._credentials, credentials)
self.assertEqual(client._connection._http, http)
self.assertIs(client._credentials, credentials)
self.assertIs(client._http_internal, http)

def test_new_project_factory(self):
from google.cloud.resource_manager.project import Project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _make_one(self, *args, **kw):
return self._get_target_class()(*args, **kw)

def test_build_api_url_no_extra_query_params(self):
conn = self._make_one()
conn = self._make_one(object())
URI = '/'.join([
conn.API_BASE_URL,
conn.API_VERSION,
Expand All @@ -39,7 +39,7 @@ def test_build_api_url_w_extra_query_params(self):
from six.moves.urllib.parse import parse_qsl
from six.moves.urllib.parse import urlsplit

conn = self._make_one()
conn = self._make_one(object())
uri = conn.build_api_url('/foo', {'bar': 'baz'})
scheme, netloc, path, qs, _ = urlsplit(uri)
self.assertEqual('%s://%s' % (scheme, netloc), conn.API_BASE_URL)
Expand Down

0 comments on commit ec85966

Please sign in to comment.