This is an automated email from the ASF dual-hosted git repository.

eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new e70bee00cd Fix `cache_control` parameter of upload function in 
`GCSHook`  (#32440)
e70bee00cd is described below

commit e70bee00cd12ecf1462485a747c0e3296ef7d48c
Author: Shahar Epstein <[email protected]>
AuthorDate: Sat Jul 8 14:05:23 2023 +0300

    Fix `cache_control` parameter of upload function in `GCSHook`  (#32440)
    
    * Fix `cache_control` parameter of upload function in `GCSHook`
    ---------
    
    Co-authored-by: Ying Wu <[email protected]>
---
 airflow/providers/google/cloud/hooks/gcs.py    |  2 +-
 tests/providers/google/cloud/hooks/test_gcs.py | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/google/cloud/hooks/gcs.py 
b/airflow/providers/google/cloud/hooks/gcs.py
index 42a27e80f8..5350c9f790 100644
--- a/airflow/providers/google/cloud/hooks/gcs.py
+++ b/airflow/providers/google/cloud/hooks/gcs.py
@@ -517,7 +517,7 @@ class GCSHook(GoogleBaseHook):
             blob.metadata = metadata
 
         if cache_control:
-            blob.cacheControl = cache_control
+            blob.cache_control = cache_control
 
         if filename and data:
             raise ValueError(
diff --git a/tests/providers/google/cloud/hooks/test_gcs.py 
b/tests/providers/google/cloud/hooks/test_gcs.py
index 9e7ff971d2..61ce7a4162 100644
--- a/tests/providers/google/cloud/hooks/test_gcs.py
+++ b/tests/providers/google/cloud/hooks/test_gcs.py
@@ -936,6 +936,19 @@ class TestGCSHookUpload:
 
         assert metadata == blob_object.return_value.metadata
 
+    @mock.patch(GCS_STRING.format("GCSHook.get_conn"))
+    def test_upload_cache_control(self, mock_service, testdata_file):
+        test_bucket = "test_bucket"
+        test_object = "test_object"
+        cache_control = "public, max-age=3600"
+
+        bucket_mock = mock_service.return_value.bucket
+        blob_object = bucket_mock.return_value.blob
+
+        self.gcs_hook.upload(test_bucket, test_object, filename=testdata_file, 
cache_control=cache_control)
+
+        assert cache_control == blob_object.return_value.cache_control
+
     @mock.patch(GCS_STRING.format("GCSHook.get_conn"))
     def test_upload_file_gzip(self, mock_service, testdata_file):
         test_bucket = "test_bucket"

Reply via email to