chrisqiqiu commented on code in PR #64755:
URL: https://github.com/apache/airflow/pull/64755#discussion_r3068197813
##########
providers/google/tests/unit/google/cloud/transfers/test_gcs_to_gcs.py:
##########
@@ -1062,3 +1062,47 @@ def
test_execute_excludes_directory_uri_from_return(self, mock_hook):
)
result = operator.execute(None)
assert result == [f"gs://{DESTINATION_BUCKET}/backup/file.txt"]
+
+ @mock.patch("airflow.providers.google.cloud.transfers.gcs_to_gcs.GCSHook")
+ def test_copy_single_file_with_retention(self, mock_hook):
+ retain_until = datetime(2027, 1, 1)
+ mock_hook.return_value.list.return_value = [SOURCE_OBJECT_NO_WILDCARD]
+ operator = GCSToGCSOperator(
+ task_id=TASK_ID,
+ source_bucket=TEST_BUCKET,
+ source_object=SOURCE_OBJECT_NO_WILDCARD,
+ destination_bucket=DESTINATION_BUCKET,
+ destination_object=SOURCE_OBJECT_NO_WILDCARD,
+ retain_until_time=retain_until,
+ retention_mode="Locked",
+ )
+
+ operator.execute(None)
+ mock_hook.return_value.rewrite.assert_called_once_with(
+ TEST_BUCKET,
+ SOURCE_OBJECT_NO_WILDCARD,
+ DESTINATION_BUCKET,
+ SOURCE_OBJECT_NO_WILDCARD,
+ retain_until_time=retain_until,
+ retention_mode="Locked",
+ )
Review Comment:
Added test_copy_single_file_with_retention_without_mode
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]