Commit 4c1c04a6 authored by Yan Sushchynski (EPAM)'s avatar Yan Sushchynski (EPAM)
Browse files

GONRG-1869: Hot fixes for FileHandler and GoogleCloudStorageClient

parent cb859e02
Pipeline #27016 passed with stages
in 11 minutes and 8 seconds
...@@ -75,12 +75,12 @@ class FileHandler(HeadersMixin): ...@@ -75,12 +75,12 @@ class FileHandler(HeadersMixin):
self.token_refresher = token_refresher self.token_refresher = token_refresher
self._blob_storage_client = blob_storage_client or blob_storage.get_client() self._blob_storage_client = blob_storage_client or blob_storage.get_client()
def _get_file_from_preload_path(self, preload_path: str, def _get_file_from_preload_path(self, preload_file_path: str,
file: FileLikeObject) -> Tuple[FileLikeObject, str]: file: FileLikeObject) -> Tuple[FileLikeObject, str]:
"""Get file from a preloaded path. """Get file from a preloaded path.
:param preload_path: Full URI of the file to obtain :param preload_file_path: Full URI of the file to obtain
:type preload_path: str :type preload_file_path: str
:return: Raw file data and content-type :return: Raw file data and content-type
:rtype: Tuple[FileLikeObject, str] :rtype: Tuple[FileLikeObject, str]
""" """
......
...@@ -104,7 +104,7 @@ class GoogleCloudStorageClient(BlobStorageClient): ...@@ -104,7 +104,7 @@ class GoogleCloudStorageClient(BlobStorageClient):
bucket = self._storage_client.bucket(bucket_name) bucket = self._storage_client.bucket(bucket_name)
blob = bucket.get_blob(source_blob_name) blob = bucket.get_blob(source_blob_name)
file_as_bytes = blob.download_as_bytes() file_as_bytes = blob.download_as_string()
logger.debug(f"File {source_blob_name} got from bucket {bucket_name}.") logger.debug(f"File {source_blob_name} got from bucket {bucket_name}.")
return file_as_bytes, blob.content_type return file_as_bytes, blob.content_type
......
...@@ -144,7 +144,7 @@ class TestGoogleCloudStorageClient: ...@@ -144,7 +144,7 @@ class TestGoogleCloudStorageClient:
client_mock.bucket.assert_called_with(bucket_name) client_mock.bucket.assert_called_with(bucket_name)
bucket_mock.get_blob.assert_called_with(blob_name) bucket_mock.get_blob.assert_called_with(blob_name)
blob_mock.download_as_bytes.assert_called_with() blob_mock.download_as_string.assert_called_with()
@pytest.mark.parametrize("uri, bucket_name, blob_name, content_type", [ @pytest.mark.parametrize("uri, bucket_name, blob_name, content_type", [
pytest.param("gs://bucket_test/name_test", "bucket_test", "name_test", "text/html"), pytest.param("gs://bucket_test/name_test", "bucket_test", "name_test", "text/html"),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment