@@ -128,6 +128,7 @@ def test_execute_no_wildcard_with_replace_flag_false(self, mock_hook):
128
128
def test_copy_file_with_exact_match (self , mock_hook ):
129
129
SOURCE_FILES = [
130
130
"test_object.txt" ,
131
+ "test_object.txt.abc" ,
131
132
"test_object.txt.copy/" ,
132
133
"test_object.txt.folder/" ,
133
134
]
@@ -145,6 +146,42 @@ def test_copy_file_with_exact_match(self, mock_hook):
145
146
mock .call (TEST_BUCKET , prefix = "test_object.txt" , delimiter = None , match_glob = None ),
146
147
]
147
148
mock_hook .return_value .list .assert_has_calls (mock_calls )
149
+ mock_hook .return_value .rewrite .assert_has_calls (
150
+ [
151
+ mock .call (TEST_BUCKET , "test_object.txt" , DESTINATION_BUCKET , "test_object.txt" ),
152
+ ]
153
+ )
154
+
155
+ @mock .patch ("airflow.providers.google.cloud.transfers.gcs_to_gcs.GCSHook" )
156
+ def test_copy_file_with_exact_match_destination (self , mock_hook ):
157
+ SOURCE_FILES = [
158
+ "test_object.txt" ,
159
+ "test_object.txt.abc" ,
160
+ "test_object.txt.copy/" ,
161
+ "test_object.txt.folder/" ,
162
+ ]
163
+ DESTINATION_OBJ = f"{ DESTINATION_OBJECT_PREFIX } /test_object.txt"
164
+
165
+ mock_hook .return_value .list .return_value = SOURCE_FILES
166
+ operator = GCSToGCSOperator (
167
+ task_id = TASK_ID ,
168
+ source_bucket = TEST_BUCKET ,
169
+ source_object = SOURCE_OBJECT_NO_WILDCARD ,
170
+ destination_bucket = DESTINATION_BUCKET ,
171
+ destination_object = DESTINATION_OBJ ,
172
+ exact_match = True ,
173
+ )
174
+
175
+ operator .execute (None )
176
+ mock_calls = [
177
+ mock .call (TEST_BUCKET , prefix = "test_object.txt" , delimiter = None , match_glob = None ),
178
+ ]
179
+ mock_hook .return_value .list .assert_has_calls (mock_calls )
180
+
181
+ mock_calls_rewrite = [
182
+ mock .call (TEST_BUCKET , "test_object.txt" , DESTINATION_BUCKET , DESTINATION_OBJ ),
183
+ ]
184
+ mock_hook .return_value .rewrite .assert_has_calls (mock_calls_rewrite )
148
185
149
186
@mock .patch ("airflow.providers.google.cloud.transfers.gcs_to_gcs.GCSHook" )
150
187
def test_execute_prefix_and_suffix (self , mock_hook ):
0 commit comments