Skip to content

Commit

Permalink
[gcloud] Cover url parameters kwarg in tests (#1408)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneier authored Jun 1, 2024
1 parent 1c6e110 commit 8d7681f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions storages/backends/gcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ def url(self, name, parameters=None):
"""
Return public URL or a signed URL for the Blob.
The existnce of blobs are not verified for public URLs, it makes the code too
slow.
To keep things snappy, the existence of blobs for public URLs is not checked.
"""
name = self._normalize_name(clean_name(name))
blob = self.bucket.blob(name)
Expand Down
8 changes: 5 additions & 3 deletions tests/test_gcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def test_url_not_public_file_with_custom_expires(self):
expiration=timedelta(seconds=3600), version="v4"
)

def test_custom_endpoint(self):
def test_custom_endpoint_with_parameters(self):
self.storage.custom_endpoint = "https://example.com"

self.storage.default_acl = "publicRead"
Expand All @@ -377,11 +377,13 @@ def test_custom_endpoint(self):
type(blob.bucket).name = mock.PropertyMock(return_value=bucket_name)
blob.generate_signed_url = generate_signed_url
self.storage._bucket.blob.return_value = blob
self.storage.url(self.filename)
parameters = {"version": "v2", "method": "POST"}
self.storage.url(self.filename, parameters=parameters)
blob.generate_signed_url.assert_called_with(
bucket_bound_hostname=self.storage.custom_endpoint,
expiration=timedelta(seconds=86400),
version="v4",
method="POST",
version="v2",
)

def test_get_available_name(self):
Expand Down

0 comments on commit 8d7681f

Please sign in to comment.