Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
added test for no quota project
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingrismore committed Oct 16, 2023
1 parent bd4f3a6 commit 4b16c59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ def google_auth(monkeypatch):
return google_auth_mock


@pytest.fixture
def google_auth_no_quota_project(monkeypatch):
google_auth_mock = MagicMock()
default_credentials_mock = MagicMock(
client_id="my_client_id", quota_project_id=None
)
google_auth_mock.default.side_effect = lambda *args, **kwargs: (
default_credentials_mock,
"my_project",
)
monkeypatch.setattr("google.auth", google_auth_mock)
return google_auth_mock


@pytest.fixture
def oauth2_credentials(monkeypatch):
CredentialsMock = MagicMock()
Expand Down
7 changes: 7 additions & 0 deletions tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ def test_block_initialization_gcloud_cli(google_auth, oauth2_credentials):
assert gcp_credentials.project == "my_project"


def test_block_initialization_metadata_server(
google_auth_no_quota_project, oauth2_credentials
):
gcp_credentials = GcpCredentials()
assert gcp_credentials.project == "my_project"


@pytest.mark.parametrize("override_project", [None, "override_project"])
def test_get_cloud_storage_client(
override_project, service_account_info, oauth2_credentials, storage_client
Expand Down

0 comments on commit 4b16c59

Please sign in to comment.