Skip to content

Commit

Permalink
Switch from oauth2client to google-auth (#2726)
Browse files Browse the repository at this point in the history
* Removes all use of oauth2client from every package and tests.
* Updates core to use google-auth's default credentials, project ID, and scoping logic.
* Updates bigtable to use google-auth's scoping logic.
  • Loading branch information
Jon Wayne Parrott authored Dec 2, 2016
1 parent ede9b4f commit bf9ca3b
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions packages/google-cloud-resource-manager/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_constructor(self):
from google.cloud.resource_manager.connection import Connection

http = object()
credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials, http=http)
self.assertIsInstance(client._connection, Connection)
self.assertEqual(client._connection._credentials, credentials)
Expand All @@ -38,7 +38,7 @@ def test_constructor(self):
def test_new_project_factory(self):
from google.cloud.resource_manager.project import Project

credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)
project_id = 'project_id'
name = object()
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_fetch_project(self):
'lifecycleState': 'ACTIVE',
}

credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)
# Patch the connection with one we can easily control.
client._connection = _Connection(project_resource)
Expand All @@ -81,7 +81,7 @@ def test_fetch_project(self):
def test_list_projects_return_type(self):
from google.cloud.iterator import HTTPIterator

credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)
# Patch the connection with one we can easily control.
client._connection = _Connection({})
Expand All @@ -90,7 +90,7 @@ def test_list_projects_return_type(self):
self.assertIsInstance(results, HTTPIterator)

def test_list_projects_no_paging(self):
credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)

PROJECT_ID = 'project-id'
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_list_projects_no_paging(self):
self.assertEqual(project.status, STATUS)

def test_list_projects_with_paging(self):
credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)

PROJECT_ID1 = 'project-id'
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_list_projects_with_paging(self):
})

def test_list_projects_with_filter(self):
credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)

PROJECT_ID = 'project-id'
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_list_projects_with_filter(self):
def test_page_empty_response(self):
from google.cloud.iterator import Page

credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)
iterator = client.list_projects()
page = Page(iterator, (), None)
Expand All @@ -246,7 +246,7 @@ def test_page_non_empty_response(self):
'lifecycleState': project_lifecycle_state,
}
response = {'projects': [api_resource]}
credentials = _Credentials()
credentials = object()
client = self._make_one(credentials=credentials)

def dummy_response():
Expand All @@ -268,19 +268,6 @@ def dummy_response():
self.assertEqual(project.status, project_lifecycle_state)


class _Credentials(object):

_scopes = None

@staticmethod
def create_scoped_required():
return True

def create_scoped(self, scope):
self._scopes = scope
return self


class _Connection(object):

def __init__(self, *responses):
Expand Down

0 comments on commit bf9ca3b

Please sign in to comment.