def test_execute(self, gcs_mock_hook, azure_fileshare_mock_hook): """Test the execute function when the run is successful.""" operator = AzureFileShareToGCSOperator( task_id=TASK_ID, share_name=AZURE_FILESHARE_SHARE, directory_name=AZURE_FILESHARE_DIRECTORY_NAME, azure_fileshare_conn_id=AZURE_FILESHARE_CONN_ID, gcp_conn_id=GCS_CONN_ID, dest_gcs=GCS_PATH_PREFIX, google_impersonation_chain=IMPERSONATION_CHAIN, ) azure_fileshare_mock_hook.return_value.list_files.return_value = MOCK_FILES uploaded_files = operator.execute(None) gcs_mock_hook.return_value.upload.assert_has_calls( [ mock.call('gcs-bucket', 'data/TEST1.csv', mock.ANY, gzip=False), mock.call('gcs-bucket', 'data/TEST3.csv', mock.ANY, gzip=False), mock.call('gcs-bucket', 'data/TEST2.csv', mock.ANY, gzip=False), ], any_order=True, ) azure_fileshare_mock_hook.assert_called_once_with(AZURE_FILESHARE_CONN_ID) gcs_mock_hook.assert_called_once_with( gcp_conn_id=GCS_CONN_ID, delegate_to=None, impersonation_chain=IMPERSONATION_CHAIN, ) assert sorted(MOCK_FILES) == sorted(uploaded_files)