Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from Oct 6, 2020

Conversation

crwilcox
Copy link
Contributor

@crwilcox crwilcox commented Oct 6, 2020

No description provided.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 6, 2020
@crwilcox crwilcox requested a review from andrewsg October 6, 2020 19:52
@crwilcox
Copy link
Contributor Author

crwilcox commented Oct 6, 2020

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

@tseaver
Copy link
Contributor

tseaver commented Oct 6, 2020

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

@crwilcox
Copy link
Contributor Author

crwilcox commented Oct 6, 2020

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

@crwilcox crwilcox changed the title fix: harden version data gathering against DistributionNotFound fix: use version.py for versioning, avoid issues with discovering version via get_distribution Oct 6, 2020
@tseaver
Copy link
Contributor

tseaver commented Oct 6, 2020

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

@tseaver
Copy link
Contributor

tseaver commented Oct 6, 2020

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

@tseaver
Copy link
Contributor

tseaver commented Oct 6, 2020

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

@crwilcox crwilcox merged commit fcd1c4f into master Oct 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants