Accepting request 970246 from home:bnavigator:branches:devel:languages:python
- Update to 2.44.0 * * : update the api * deps: require google-api-core>=1.31.5, >=2.3.2 (#1715) (8308e5d) * remove adsense.v1.4.json (#1616) (5d3e588) * expose library version at googleapiclient.version (#1623) (83db1d7) * deps: require uritemplate 3.0.1 (#1629) (1c4cfdb) - Do not test deprecated oauth2client anymore: * add opensuse-remove-oauth2client-tests.patch OBS-URL: https://build.opensuse.org/request/show/970246 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-google-api-python-client?expand=0&rev=45
This commit is contained in:
165
opensuse-remove-oauth2client-tests.patch
Normal file
165
opensuse-remove-oauth2client-tests.patch
Normal file
@@ -0,0 +1,165 @@
|
||||
Index: google-api-python-client-2.44.0/tests/test__auth.py
|
||||
===================================================================
|
||||
--- google-api-python-client-2.44.0.orig/tests/test__auth.py
|
||||
+++ google-api-python-client-2.44.0/tests/test__auth.py
|
||||
@@ -18,7 +18,6 @@ import mock
|
||||
import google.auth.credentials
|
||||
import google_auth_httplib2
|
||||
import httplib2
|
||||
-import oauth2client.client
|
||||
|
||||
from googleapiclient import _auth
|
||||
|
||||
@@ -26,11 +25,9 @@ from googleapiclient import _auth
|
||||
class TestAuthWithGoogleAuth(unittest.TestCase):
|
||||
def setUp(self):
|
||||
_auth.HAS_GOOGLE_AUTH = True
|
||||
- _auth.HAS_OAUTH2CLIENT = False
|
||||
|
||||
def tearDown(self):
|
||||
_auth.HAS_GOOGLE_AUTH = True
|
||||
- _auth.HAS_OAUTH2CLIENT = True
|
||||
|
||||
def test_default_credentials(self):
|
||||
with mock.patch("google.auth.default", autospec=True) as default:
|
||||
@@ -103,75 +100,12 @@ class TestAuthWithGoogleAuth(unittest.Te
|
||||
self.assertGreater(authorized_http.http.timeout, 0)
|
||||
|
||||
|
||||
-class TestAuthWithOAuth2Client(unittest.TestCase):
|
||||
- def setUp(self):
|
||||
- _auth.HAS_GOOGLE_AUTH = False
|
||||
- _auth.HAS_OAUTH2CLIENT = True
|
||||
-
|
||||
- def tearDown(self):
|
||||
- _auth.HAS_GOOGLE_AUTH = True
|
||||
- _auth.HAS_OAUTH2CLIENT = True
|
||||
-
|
||||
- def test_default_credentials(self):
|
||||
- default_patch = mock.patch(
|
||||
- "oauth2client.client.GoogleCredentials.get_application_default"
|
||||
- )
|
||||
-
|
||||
- with default_patch as default:
|
||||
- default.return_value = mock.sentinel.credentials
|
||||
-
|
||||
- credentials = _auth.default_credentials()
|
||||
-
|
||||
- self.assertEqual(credentials, mock.sentinel.credentials)
|
||||
-
|
||||
- def test_credentials_from_file(self):
|
||||
- with self.assertRaises(EnvironmentError):
|
||||
- credentials = _auth.credentials_from_file("credentials.json")
|
||||
-
|
||||
- def test_default_credentials_with_scopes_and_quota_project(self):
|
||||
- with self.assertRaises(EnvironmentError):
|
||||
- credentials = _auth.default_credentials(
|
||||
- scopes=["1", "2"], quota_project_id="my-project"
|
||||
- )
|
||||
-
|
||||
- def test_with_scopes_non_scoped(self):
|
||||
- credentials = mock.Mock(spec=oauth2client.client.Credentials)
|
||||
-
|
||||
- returned = _auth.with_scopes(credentials, mock.sentinel.scopes)
|
||||
-
|
||||
- self.assertEqual(credentials, returned)
|
||||
-
|
||||
- def test_with_scopes_scoped(self):
|
||||
- credentials = mock.Mock(spec=oauth2client.client.GoogleCredentials)
|
||||
- credentials.create_scoped_required.return_value = True
|
||||
-
|
||||
- returned = _auth.with_scopes(credentials, mock.sentinel.scopes)
|
||||
-
|
||||
- self.assertNotEqual(credentials, returned)
|
||||
- self.assertEqual(returned, credentials.create_scoped.return_value)
|
||||
- credentials.create_scoped.assert_called_once_with(mock.sentinel.scopes)
|
||||
-
|
||||
- def test_authorized_http(self):
|
||||
- credentials = mock.Mock(spec=oauth2client.client.Credentials)
|
||||
-
|
||||
- authorized_http = _auth.authorized_http(credentials)
|
||||
-
|
||||
- http = credentials.authorize.call_args[0][0]
|
||||
-
|
||||
- self.assertEqual(authorized_http, credentials.authorize.return_value)
|
||||
- self.assertIsInstance(http, httplib2.Http)
|
||||
- self.assertIsInstance(http.timeout, int)
|
||||
- self.assertGreater(http.timeout, 0)
|
||||
-
|
||||
-
|
||||
class TestAuthWithoutAuth(unittest.TestCase):
|
||||
def setUp(self):
|
||||
_auth.HAS_GOOGLE_AUTH = False
|
||||
- _auth.HAS_OAUTH2CLIENT = False
|
||||
|
||||
def tearDown(self):
|
||||
_auth.HAS_GOOGLE_AUTH = True
|
||||
- _auth.HAS_OAUTH2CLIENT = True
|
||||
|
||||
def test_default_credentials(self):
|
||||
with self.assertRaises(EnvironmentError):
|
||||
Index: google-api-python-client-2.44.0/tests/test_discovery.py
|
||||
===================================================================
|
||||
--- google-api-python-client-2.44.0.orig/tests/test_discovery.py
|
||||
+++ google-api-python-client-2.44.0/tests/test_discovery.py
|
||||
@@ -82,8 +82,6 @@ from googleapiclient.http import MediaUp
|
||||
from googleapiclient.http import tunnel_patch
|
||||
from googleapiclient.model import JsonModel
|
||||
from googleapiclient.schema import Schemas
|
||||
-from oauth2client import GOOGLE_TOKEN_URI
|
||||
-from oauth2client.client import OAuth2Credentials, GoogleCredentials
|
||||
|
||||
|
||||
from googleapiclient import _helpers as util
|
||||
@@ -1420,14 +1418,6 @@ class Discovery(unittest.TestCase):
|
||||
self.assertTrue(getattr(plus, "activities"))
|
||||
self.assertTrue(getattr(plus, "people"))
|
||||
|
||||
- def test_oauth2client_credentials(self):
|
||||
- credentials = mock.Mock(spec=GoogleCredentials)
|
||||
- credentials.create_scoped_required.return_value = False
|
||||
-
|
||||
- discovery = read_datafile("plus.json")
|
||||
- service = build_from_document(discovery, credentials=credentials)
|
||||
- self.assertEqual(service._http, credentials.authorize.return_value)
|
||||
-
|
||||
def test_google_auth_credentials(self):
|
||||
credentials = mock.Mock(spec=google.auth.credentials.Credentials)
|
||||
discovery = read_datafile("plus.json")
|
||||
@@ -2088,36 +2078,6 @@ class Discovery(unittest.TestCase):
|
||||
http.request = wrapped_request
|
||||
return http
|
||||
|
||||
- def _dummy_token(self):
|
||||
- access_token = "foo"
|
||||
- client_id = "some_client_id"
|
||||
- client_secret = "cOuDdkfjxxnv+"
|
||||
- refresh_token = "1/0/a.df219fjls0"
|
||||
- token_expiry = datetime.datetime.utcnow()
|
||||
- user_agent = "refresh_checker/1.0"
|
||||
- return OAuth2Credentials(
|
||||
- access_token,
|
||||
- client_id,
|
||||
- client_secret,
|
||||
- refresh_token,
|
||||
- token_expiry,
|
||||
- GOOGLE_TOKEN_URI,
|
||||
- user_agent,
|
||||
- )
|
||||
-
|
||||
- def test_pickle_with_credentials(self):
|
||||
- credentials = self._dummy_token()
|
||||
- http = self._dummy_zoo_request()
|
||||
- http = credentials.authorize(http)
|
||||
- self.assertTrue(hasattr(http.request, "credentials"))
|
||||
-
|
||||
- zoo = build("zoo", "v1", http=http, static_discovery=False)
|
||||
- pickled_zoo = pickle.dumps(zoo)
|
||||
- new_zoo = pickle.loads(pickled_zoo)
|
||||
- self.assertEqual(sorted(zoo.__dict__.keys()), sorted(new_zoo.__dict__.keys()))
|
||||
- new_http = new_zoo._http
|
||||
- self.assertFalse(hasattr(new_http.request, "credentials"))
|
||||
-
|
||||
def test_resumable_media_upload_no_content(self):
|
||||
self.http = HttpMock(datafile("zoo.json"), {"status": "200"})
|
||||
zoo = build("zoo", "v1", http=self.http, static_discovery=False)
|
||||
Reference in New Issue
Block a user