Skip to content

Commit

Permalink
tests: fix unit tests broken by dependency drift (googleapis#430)
Browse files Browse the repository at this point in the history
* tests: fix 'TestClient.test_ctor_wo_project'

Broken by googleapis/python-cloud-core#51

Closes googleapis#427

* chore(deps): pin googleapis-common-protos' FBO python2.7

Closes googleapis#429
  • Loading branch information
tseaver authored and cojenco committed Oct 13, 2021
1 parent 9c56e9a commit c5bf17b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"google-cloud-core >= 1.4.1, < 2.0dev",
"google-resumable-media >= 1.2.0, < 2.0dev",
"requests >= 2.18.0, < 3.0.0dev",
"googleapis-common-protos < 1.53.0; python_version<'3.0'",
]
extras = {}

Expand Down
14 changes: 6 additions & 8 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
_FAKE_CREDENTIALS = Credentials.from_service_account_info(_SERVICE_ACCOUNT_JSON)


def _make_credentials():
def _make_credentials(project=None):
import google.auth.credentials

if project is not None:
return mock.Mock(spec=google.auth.credentials.Credentials, project_id=project)

return mock.Mock(spec=google.auth.credentials.Credentials)


Expand Down Expand Up @@ -174,14 +177,9 @@ def test_ctor_wo_project(self):
from google.cloud.storage._http import Connection

PROJECT = "PROJECT"
credentials = _make_credentials()
credentials = _make_credentials(project=PROJECT)

ddp_patch = mock.patch(
"google.cloud.client._determine_default_project", return_value=PROJECT
)

with ddp_patch:
client = self._make_one(credentials=credentials)
client = self._make_one(credentials=credentials)

self.assertEqual(client.project, PROJECT)
self.assertIsInstance(client._connection, Connection)
Expand Down

0 comments on commit c5bf17b

Please sign in to comment.