Skip to content

Commit

Permalink
refactor: port #561 split 'with_quota_project' into separate base class
Browse files Browse the repository at this point in the history
  • Loading branch information
crwilcox committed Sep 25, 2020
1 parent 565e2cb commit 072283e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 4 additions & 0 deletions google/auth/_credentials_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ async def before_request(self, request, method, url, headers):
self.apply(headers)


class CredentialsWithQuotaProject(credentials.CredentialsWithQuotaProject):
"""Abstract base for credentials supporting ``with_quota_project`` factory"""


class AnonymousCredentials(credentials.AnonymousCredentials, Credentials):
"""Credentials that do not provide any authentication information.
Expand Down
2 changes: 1 addition & 1 deletion tests_async/test__default_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import google.oauth2.credentials
from tests import test__default as test_default

MOCK_CREDENTIALS = mock.Mock(spec=credentials.Credentials)
MOCK_CREDENTIALS = mock.Mock(spec=credentials.CredentialsWithQuotaProject)
MOCK_CREDENTIALS.with_quota_project.return_value = MOCK_CREDENTIALS

LOAD_FILE_PATCH = mock.patch(
Expand Down
6 changes: 0 additions & 6 deletions tests_async/test_credentials_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ def test_anonymous_credentials_before_request():
assert headers == {}


def test_anonymous_credentials_with_quota_project():
with pytest.raises(ValueError):
anon = credentials.AnonymousCredentials()
anon.with_quota_project("project-foo")


class ReadOnlyScopedCredentialsImpl(credentials.ReadOnlyScoped, CredentialsImpl):
@property
def requires_scopes(self):
Expand Down

0 comments on commit 072283e

Please sign in to comment.