Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
oittaa committed Aug 3, 2024
1 parent 64291ef commit 151abe1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
20 changes: 12 additions & 8 deletions src/gcp_storage_emulator/handlers/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,14 @@ def rewrite(request, response, storage, *args, **kwargs):
file,
dest_obj,
)
response.json({
"resource": dest_obj,
"written": dest_obj["size"],
"size": dest_obj["size"],
"done": True,
})
response.json(
{
"resource": dest_obj,
"written": dest_obj["size"],
"size": dest_obj["size"],
"done": True,
}
)
except NotFound:
response.status = HTTPStatus.NOT_FOUND
except Conflict as err:
Expand Down Expand Up @@ -510,8 +512,10 @@ def download(request, response, storage, *args, **kwargs):
hash_header = "crc32c={},md5={}".format(obj["crc32c"], obj["md5Hash"])
response[_HASH_HEADER] = hash_header

if 'response-content-disposition' in request.query:
response['Content-Disposition'] = request.query['response-content-disposition'][0]
if "response-content-disposition" in request.query:
response["Content-Disposition"] = request.query[
"response-content-disposition"
][0]

response.write_file(file, content_type=obj.get("contentType"))
except NotFound:
Expand Down
11 changes: 7 additions & 4 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ def test_signed_url_download_with_content_disposition(self):
blob = bucket.blob("signed-download")
blob.upload_from_string(content, content_type="text/mycustom")

requested_filename = 'requested_filename.cst2'
requested_filename = "requested_filename.cst2"
response_disposition = f'attachment; filename="{requested_filename}"'

url = blob.generate_signed_url(
Expand All @@ -832,17 +832,20 @@ def test_signed_url_download_with_content_disposition(self):
response = requests.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, content)
self.assertEqual(response.headers['content-disposition'], f"{response_disposition}")
self.assertEqual(
response.headers["content-disposition"], f"{response_disposition}"
)
self.assertEqual(response.headers["content-type"], "text/mycustom")

def test_url_generation_for_browser(self):
self.skipTest('Used to test browser functionality with URL, not API.')
self.skipTest("Used to test browser functionality with URL, not API.")
os.environ["STORAGE_EMULATOR_HOST"] = "http://localhost:8080"
content = b"The quick brown fox jumps over the lazy dog"

# Cloud Storage uses environment variables to configure API endpoints for
# file upload - which is read at module import time
from google.cloud import storage

http = requests.Session()

client = storage.Client(
Expand All @@ -856,7 +859,7 @@ def test_url_generation_for_browser(self):
blob = bucket.blob("signed-download")
blob.upload_from_string(content, content_type="text/html")

requested_filename = 'requested_filename.cst2'
requested_filename = "requested_filename.cst2"
response_disposition = f'attachment; filename="{requested_filename}"'

url = blob.generate_signed_url(
Expand Down

0 comments on commit 151abe1

Please sign in to comment.