Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

tests: avoid requiring real credentials in unit tests - #459

Merged
tseaver merged 3 commits into
masterfrom
416-avoid_real_client_in_bucket_blob_unit_tests
Jun 9, 2021
Merged

tests: avoid requiring real credentials in unit tests#459
tseaver merged 3 commits into
masterfrom
416-avoid_real_client_in_bucket_blob_unit_tests

Conversation

@tseaver

Copy link
Copy Markdown
Contributor

Fixes#416

Also, adjust 'Bucket.get_upload_policy' to use credentials from the client,
rather than its connection.
Remove last uses of '_Client' and '_Connection' shims: use a mocked
client instead.
Toward #416.
@tseaver
tseaver requested review from a team, andrewsg and chrisrossiJune 8, 2021 20:30
@product-auto-labelproduct-auto-labelBot added the api: storage Issues related to the googleapis/python-storage API. label Jun 8, 2021
@google-clagoogle-claBot added the cla: yes This human has signed the Contributor License Agreement. label Jun 8, 2021
@tseaver
tseaverforce-pushed the 416-avoid_real_client_in_bucket_blob_unit_tests branch from cc643b2 to a694cabCompareJune 8, 2021 21:11
@tseavertseaver added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 8, 2021
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 8, 2021
@tseaver
tseaver requested review from frankyn and tritoneJune 8, 2021 21:26

client.list_blobs.assert_called_once()

def test_page_empty_response(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these tests being removed?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are non-unit tests (they really only test the already-well-tested api_core.page_iterator.Iterator). The local bits are replaced by the (new) explicit tests of _item_to_blob and _blobs_page_start (at the top of the file).

response.request = requests.Request("POST", "http://example.com").prepare()
return response

def test__extract_headers_from_download_gzipped(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding coverage, too?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests were misnamed, and out of place: I just fixed that, and split a couple of over-large ones.

@chrisrossichrisrossi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tseaver
tseaver merged commit 2c87f2f into masterJun 9, 2021
@tseaver
tseaver deleted the 416-avoid_real_client_in_bucket_blob_unit_tests branch June 9, 2021 18:43
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
Adjust 'Bucket.get_upload_policy' to use credentials from the client,
rather than its connection.
Closesgoogleapis#416.
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
Adjust 'Bucket.get_upload_policy' to use credentials from the client,
rather than its connection.
Closesgoogleapis#416.
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: storageIssues related to the googleapis/python-storage API.cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests must not depend on environment variables

3 participants

@tseaver@chrisrossi@yoshi-kokoro