예제 #1
0
 def test_execute(self, mock_hook):
     op = BigQueryDeleteDataTransferConfigOperator(
         transfer_config_id=TRANSFER_CONFIG_ID, task_id="id", project_id=PROJECT_ID
     )
     op.execute(None)
     mock_hook.return_value.delete_transfer_config.assert_called_once_with(
         metadata=None,
         transfer_config_id=TRANSFER_CONFIG_ID,
         project_id=PROJECT_ID,
         retry=None,
         timeout=None,
     )
예제 #2
0
    # [START howto_bigquery_start_transfer]
    gcp_bigquery_start_transfer = BigQueryDataTransferServiceStartTransferRunsOperator(
        task_id="gcp_bigquery_start_transfer",
        transfer_config_id=transfer_config_id,
        requested_run_time={"seconds": int(time.time() + 60)},
    )
    run_id = "{{ task_instance.xcom_pull('gcp_bigquery_start_transfer', key='run_id') }}"
    # [END howto_bigquery_start_transfer]

    # [START howto_bigquery_dts_sensor]
    gcp_run_sensor = BigQueryDataTransferServiceTransferRunSensor(
        task_id="gcp_run_sensor",
        transfer_config_id=transfer_config_id,
        run_id=run_id,
        expected_statuses={"SUCCEEDED"},
    )
    # [END howto_bigquery_dts_sensor]

    # [START howto_bigquery_delete_data_transfer]
    gcp_bigquery_delete_transfer = BigQueryDeleteDataTransferConfigOperator(
        transfer_config_id=transfer_config_id, task_id="gcp_bigquery_delete_transfer"
    )
    # [END howto_bigquery_delete_data_transfer]

    (
        gcp_bigquery_create_transfer  # noqa
        >> gcp_bigquery_start_transfer  # noqa
        >> gcp_run_sensor  # noqa
        >> gcp_bigquery_delete_transfer  # noqa
    )