本文整理匯總了Python中airflow.contrib.operators.gcs_to_gcs.GoogleCloudStorageToGoogleCloudStorageOperator類的典型用法代碼示例。如果您正苦於以下問題:Python GoogleCloudStorageToGoogleCloudStorageOperator類的具體用法?Python GoogleCloudStorageToGoogleCloudStorageOperator怎麽用?Python GoogleCloudStorageToGoogleCloudStorageOperator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GoogleCloudStorageToGoogleCloudStorageOperator類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_execute_no_suffix_without_destination_object
def test_execute_no_suffix_without_destination_object(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_2,
destination_bucket=DESTINATION_BUCKET)
operator.execute(None)
mock_hook.return_value.copy.assert_has_calls(MOCK_CALLS_EMPTY)
示例2: test_execute_prefix_and_suffix
def test_execute_prefix_and_suffix(self, mock_hook):
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_WILDCARD_MIDDLE,
destination_bucket=DESTINATION_BUCKET)
operator.execute(None)
mock_hook.return_value.list.assert_called_once_with(
TEST_BUCKET, prefix="test", delimiter="object"
)
示例3: test_no_prefix_with_last_modified_time_with_false_cond
def test_no_prefix_with_last_modified_time_with_false_cond(self, mock_hook):
mock_hook.return_value.is_updated_after.return_value = False
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_NO_WILDCARD,
destination_bucket=DESTINATION_BUCKET,
destination_object=SOURCE_OBJECT_NO_WILDCARD,
last_modified_time=MOD_TIME_1)
operator.execute(None)
mock_hook.return_value.rewrite.assert_not_called()
示例4: test_execute_no_prefix_with_no_last_modified_time
def test_execute_no_prefix_with_no_last_modified_time(self, mock_hook):
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_NO_WILDCARD,
destination_bucket=DESTINATION_BUCKET,
destination_object=SOURCE_OBJECT_NO_WILDCARD,
last_modified_time=None)
operator.execute(None)
mock_hook.return_value.rewrite.assert_called_once_with(
TEST_BUCKET, 'test_object.txt', DESTINATION_BUCKET, 'test_object.txt')
示例5: test_wc_with_last_modified_time_with_one_true_cond
def test_wc_with_last_modified_time_with_one_true_cond(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
mock_hook.return_value.is_updated_after.side_effect = [True, False, False]
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_WILDCARD_FILENAME,
destination_bucket=DESTINATION_BUCKET,
last_modified_time=MOD_TIME_1)
operator.execute(None)
mock_hook.return_value.rewrite.assert_called_once_with(
TEST_BUCKET, 'test_object/file1.txt',
DESTINATION_BUCKET, 'test_object/file1.txt')
示例6: test_execute_with_empty_destination_bucket
def test_execute_with_empty_destination_bucket(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_NO_WILDCARD,
destination_bucket=None,
destination_object=DESTINATION_OBJECT_PREFIX)
with patch.object(operator.log, 'warning') as mock_warn:
operator.execute(None)
mock_warn.assert_called_with(
'destination_bucket is None. Defaulting it to source_bucket (%s)',
TEST_BUCKET
)
self.assertEquals(operator.destination_bucket, operator.source_bucket)
示例7: test_execute_more_than_1_wildcard
def test_execute_more_than_1_wildcard(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_MULTIPLE_WILDCARDS,
destination_bucket=DESTINATION_BUCKET,
destination_object=DESTINATION_OBJECT_PREFIX)
total_wildcards = operator.source_object.count(WILDCARD)
error_msg = "Only one wildcard '[*]' is allowed in source_object parameter. " \
"Found {}".format(total_wildcards, SOURCE_OBJECT_MULTIPLE_WILDCARDS)
with self.assertRaisesRegexp(AirflowException, error_msg):
operator.execute(None)
示例8: test_execute_wildcard_without_destination_object
def test_execute_wildcard_without_destination_object(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_WILDCARD_FILENAME,
destination_bucket=DESTINATION_BUCKET)
operator.execute(None)
mock_calls_none = [
mock.call(TEST_BUCKET, 'test_object/file1.txt',
DESTINATION_BUCKET, 'test_object/file1.txt'),
mock.call(TEST_BUCKET, 'test_object/file2.txt',
DESTINATION_BUCKET, 'test_object/file2.txt'),
]
mock_hook.return_value.rewrite.assert_has_calls(mock_calls_none)
示例9: test_execute_wildcard_with_destination_object
def test_execute_wildcard_with_destination_object(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_4,
destination_bucket=DESTINATION_BUCKET,
destination_object=DESTINATION_OBJECT_PREFIX)
operator.execute(None)
mock_calls = [
mock.call(TEST_BUCKET, 'test_object/file1.txt',
DESTINATION_BUCKET, 'foo/bar/file1.txt'),
mock.call(TEST_BUCKET, 'test_object/file2.txt',
DESTINATION_BUCKET, 'foo/bar/file2.txt'),
]
mock_hook.return_value.copy.assert_has_calls(mock_calls)
示例10: test_wc_with_no_last_modified_time
def test_wc_with_no_last_modified_time(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_4,
destination_bucket=DESTINATION_BUCKET,
last_modified_time=None)
operator.execute(None)
mock_calls_none = [
mock.call(TEST_BUCKET, 'test_object/file1.txt',
DESTINATION_BUCKET, 'test_object/file1.txt'),
mock.call(TEST_BUCKET, 'test_object/file2.txt',
DESTINATION_BUCKET, 'test_object/file2.txt'),
]
mock_hook.return_value.rewrite.assert_has_calls(mock_calls_none)
示例11: test_execute_wildcard_with_destination_object_retained_prefix
def test_execute_wildcard_with_destination_object_retained_prefix(self, mock_hook):
mock_hook.return_value.list.return_value = SOURCE_FILES_LIST
operator = GoogleCloudStorageToGoogleCloudStorageOperator(
task_id=TASK_ID, source_bucket=TEST_BUCKET,
source_object=SOURCE_OBJECT_WILDCARD_FILENAME,
destination_bucket=DESTINATION_BUCKET,
destination_object='{}/{}'.format(DESTINATION_OBJECT_PREFIX,
SOURCE_OBJECT_WILDCARD_SUFFIX[:-1])
)
operator.execute(None)
mock_calls_retained = [
mock.call(TEST_BUCKET, 'test_object/file1.txt',
DESTINATION_BUCKET, 'foo/bar/test_object/file1.txt'),
mock.call(TEST_BUCKET, 'test_object/file2.txt',
DESTINATION_BUCKET, 'foo/bar/test_object/file2.txt'),
]
mock_hook.return_value.rewrite.assert_has_calls(mock_calls_retained)