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

fix: use version.py for versioning, avoid issues with discovering version via get_distribution - #288

Merged
crwilcox merged 7 commits into
masterfrom
guard-get-distribution
Oct 6, 2020
Merged

fix: use version.py for versioning, avoid issues with discovering version via get_distribution#288
crwilcox merged 7 commits into
masterfrom
guard-get-distribution

Conversation

@crwilcox

Copy link
Copy Markdown
Contributor

No description provided.

@google-clagoogle-claBot added the cla: yes This human has signed the Contributor License Agreement. label Oct 6, 2020
@crwilcox
crwilcox requested a review from andrewsgOctober 6, 2020 19:52
Comment threadgoogle/cloud/storage/__init__.py Outdated
@crwilcox
crwilcoxforce-pushed the guard-get-distribution branch from e9fb6f3 to 42ef9b7CompareOctober 6, 2020 20:18
@crwilcox
crwilcoxforce-pushed the guard-get-distribution branch from 42ef9b7 to 4e73155CompareOctober 6, 2020 20:24
@crwilcox

Copy link
Copy Markdown
ContributorAuthor

As it is a bit more robust, I added version.py to google-cloud-storage

@tseaver

Copy link
Copy Markdown
Contributor

@crwilcox Needs a git add google/cloud/storage/version.py.

@crwilcox

crwilcox commented Oct 6, 2020

Copy link
Copy Markdown
ContributorAuthor

Test failures seem unrelated to me?

_______________________________________________________________ TestClient.test_lookup_bucket_with_metageneration_match ________________________________________________________________
self = <tests.unit.test_client.TestClient testMethod=test_lookup_bucket_with_metageneration_match>
def test_lookup_bucket_with_metageneration_match(self):
from google.cloud.storage.bucket import Bucket
PROJECT = "PROJECT"
CREDENTIALS = _make_credentials()
METAGENERATION_NUMBER = 6
client = self._make_one(project=PROJECT, credentials=CREDENTIALS)
BUCKET_NAME = "bucket-name"
URI1 = "/".join(
[
client._connection.API_BASE_URL,
"storage",
client._connection.API_VERSION,
"b",
"%s?projection=noAcl&ifMetagenerationMatch=%s"
% (BUCKET_NAME, METAGENERATION_NUMBER),
]
)
URI2 = "/".join(
[
client._connection.API_BASE_URL,
"storage",
client._connection.API_VERSION,
"b",
"%s?ifMetagenerationMatch=%s&projection=noAcl"
% (BUCKET_NAME, METAGENERATION_NUMBER),
]
)
data = {"name": BUCKET_NAME}
http = _make_requests_session([_make_json_response(data)])
client._http_internal = http
bucket = client.lookup_bucket(
BUCKET_NAME, if_metageneration_match=METAGENERATION_NUMBER
)
self.assertIsInstance(bucket, Bucket)
self.assertEqual(bucket.name, BUCKET_NAME)
http.request.assert_called_once_with(
method="GET",
url=mock.ANY,
data=mock.ANY,
headers=mock.ANY,
timeout=self._get_default_timeout(),
)
_, kwargs = http.request.call_args
> self.assertIn(kwargs.get("url"), (URI1, URI2))
E AssertionError: 'https://storage.googleapis.com/storage/v1/b/bucket-name?projection=noAcl&ifMetagenerationMatch=6&prettyPrint=false' not found in ('https://storage.googleapis.com/storage/v1/b/bucket-name?projection=noAcl&ifMetagenerationMatch=6', 'https://storage.googleapis.com/storage/v1/b/bucket-name?ifMetagenerationMatch=6&projection=noAcl')
tests/unit/test_client.py:663: AssertionError

Seems prettyPrint is showing up? Confirmed same failures on master. @andrewsg

@crwilcoxcrwilcox changed the title fix: harden version data gathering against DistributionNotFoundfix: use version.py for versioning, avoid issues with discovering version via get_distributionOct 6, 2020
@tseaver

tseaver commented Oct 6, 2020

Copy link
Copy Markdown
Contributor

@crwilcox&prettyPrint=False got added to URLs via https://www.github.com/googleapis/python-cloud-core/pull/28.

@tseaver

tseaver commented Oct 6, 2020

Copy link
Copy Markdown
Contributor

We need to pull in @tswast's changes from #277 to get the tests to pass on latest google-cloud-core.

@tseaver

Copy link
Copy Markdown
Contributor

@crwilcox I just merged #277 to fix the tests on master.

@crwilcox
crwilcox merged commit fcd1c4f into masterOct 6, 2020
@tseaver
tseaver deleted the guard-get-distribution branch August 24, 2021 18:07
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
…sion via get_distribution (googleapis#288)
Co-authored-by: Tres Seaver <tseaver@palladion.com>
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
…sion via get_distribution (googleapis#288)
Co-authored-by: Tres Seaver <tseaver@palladion.com>
@release-pleaserelease-pleaseBot mentioned this pull request Jan 12, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@crwilcox@tseaver@frankyn