From 3404cbce2fa587defc1d52c0d03fc3c8cc9d85b5 Mon Sep 17 00:00:00 2001
From: Ernesto Gutierrez <ernesto_gutierrez@epam.com>
Date: Mon, 8 Feb 2021 07:34:53 -0600
Subject: [PATCH] Fix download_as_bytes not supported in storage==1.13.2

---
 src/dags/providers/gcp/gcp_blob_storage_client.py          | 2 +-
 tests/providers-unit-tests/test_gcp_blob_storage_client.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/dags/providers/gcp/gcp_blob_storage_client.py b/src/dags/providers/gcp/gcp_blob_storage_client.py
index 10bd4b3..8a6deae 100644
--- a/src/dags/providers/gcp/gcp_blob_storage_client.py
+++ b/src/dags/providers/gcp/gcp_blob_storage_client.py
@@ -104,7 +104,7 @@ class GoogleCloudStorageClient(BlobStorageClient):
         bucket = self._storage_client.bucket(bucket_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}.")
 
         return file_as_bytes, blob.content_type
diff --git a/tests/providers-unit-tests/test_gcp_blob_storage_client.py b/tests/providers-unit-tests/test_gcp_blob_storage_client.py
index f80e94b..856180c 100644
--- a/tests/providers-unit-tests/test_gcp_blob_storage_client.py
+++ b/tests/providers-unit-tests/test_gcp_blob_storage_client.py
@@ -144,7 +144,7 @@ class TestGoogleCloudStorageClient:
 
         client_mock.bucket.assert_called_with(bucket_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.param("gs://bucket_test/name_test", "bucket_test", "name_test", "text/html"),
-- 
GitLab