def test_job_update(self, mock_hook): mock_hook.return_value.update_transfer_job.return_value = VALID_TRANSFER_JOB_GCS body = {'transferJob': {'description': 'example-name'}, 'updateTransferJobFieldMask': DESCRIPTION} op = GcpTransferServiceJobUpdateOperator(job_name=JOB_NAME, body=body, task_id=TASK_ID) result = op.execute(None) mock_hook.assert_called_once_with(api_version='v1', gcp_conn_id='google_cloud_default') mock_hook.return_value.update_transfer_job.assert_called_once_with(job_name=JOB_NAME, body=body) self.assertEqual(result, VALID_TRANSFER_JOB_GCS)
def test_templates(self, _): dag_id = 'test_dag_id' args = {'start_date': DEFAULT_DATE} self.dag = DAG(dag_id, default_args=args) # pylint:disable=attribute-defined-outside-init op = GcpTransferServiceJobUpdateOperator( job_name='{{ dag.dag_id }}', body={'transferJob': {"name": "{{ dag.dag_id }}"}}, task_id='task-id', dag=self.dag, ) ti = TaskInstance(op, DEFAULT_DATE) ti.render_templates() self.assertEqual(dag_id, getattr(op, 'body')['transferJob']['name']) self.assertEqual(dag_id, getattr(op, 'job_name'))
def test_templates(self, _): dag_id = 'test_dag_id' configuration.load_test_config() args = {'start_date': DEFAULT_DATE} self.dag = DAG(dag_id, default_args=args) op = GcpTransferServiceJobUpdateOperator( job_name='{{ dag.dag_id }}', body={'transferJob': {"name": "{{ dag.dag_id }}"}}, task_id='task-id', dag=self.dag, ) ti = TaskInstance(op, DEFAULT_DATE) ti.render_templates() self.assertEqual(dag_id, getattr(op, 'body')['transferJob']['name']) self.assertEqual(dag_id, getattr(op, 'job_name'))
poke_interval=WAIT_FOR_OPERATION_POKE_INTERVAL, ) # [START howto_operator_gcp_transfer_pause_operation] pause_operation = GcpTransferServiceOperationPauseOperator( task_id="pause_operation", operation_name= "{{task_instance.xcom_pull('wait_for_operation_to_start', " "key='sensed_operations')[0]['name']}}", ) # [END howto_operator_gcp_transfer_pause_operation] # [START howto_operator_gcp_transfer_update_job] update_job = GcpTransferServiceJobUpdateOperator( task_id="update_job", job_name= "{{task_instance.xcom_pull('create_transfer_job_from_aws')['name']}}", body=update_body, ) # [END howto_operator_gcp_transfer_update_job] # [START howto_operator_gcp_transfer_list_operations] list_operations = GcpTransferServiceOperationsListOperator( task_id="list_operations", request_filter={ FILTER_PROJECT_ID: GCP_PROJECT_ID, FILTER_JOB_NAMES: [ "{{task_instance.xcom_pull('create_transfer_job_from_aws')['name']}}" ], }, )