def test_execute(self, gcs_hook_mock, hook_mock, mock_tempfile): filename = "filename" object_name = "object_name" bucket_name = "bucket_name" line_items = "holy_hand_grenade" gcs_hook_mock.return_value.download.return_value = line_items mock_tempfile.NamedTemporaryFile.return_value.__enter__.return_value.name = ( filename) op = GoogleDisplayVideo360UploadLineItemsOperator( bucket_name=bucket_name, object_name=object_name, api_version=API_VERSION, gcp_conn_id=GCP_CONN_ID, task_id="test_task", ) op.execute(context=None) hook_mock.assert_called_once_with(gcp_conn_id=GCP_CONN_ID, api_version=API_VERSION, delegate_to=DELEGATE_TO) gcs_hook_mock.assert_called_once_with( gcp_conn_id=GCP_CONN_ID, delegate_to=DELEGATE_TO, ) gcs_hook_mock.return_value.download.assert_called_once_with( bucket_name=bucket_name, object_name=object_name, filename=filename, ) hook_mock.return_value.upload_line_items.assert_called_once() hook_mock.return_value.upload_line_items.assert_called_once_with( line_items=line_items)
# [END howto_google_display_video_upload_multiple_entity_read_files_to_big_query] # [START howto_google_display_video_download_line_items_operator] download_line_items = GoogleDisplayVideo360DownloadLineItemsOperator( task_id="download_line_items", request_body=DOWNLOAD_LINE_ITEMS_REQUEST, bucket_name=BUCKET, object_name=OBJECT_NAME, gzip=False, ) # [END howto_google_display_video_download_line_items_operator] # [START howto_google_display_video_upload_line_items_operator] upload_line_items = GoogleDisplayVideo360UploadLineItemsOperator( task_id="upload_line_items", bucket_name=BUCKET, object_name=BUCKET_FILE_LOCATION, ) # [END howto_google_display_video_upload_line_items_operator] with models.DAG( "example_display_video_sdf", schedule_interval=None, # Override to match your needs, start_date=dates.days_ago(1), ) as dag3: # [START howto_google_display_video_create_sdf_download_task_operator] create_sdf_download_task = GoogleDisplayVideo360CreateSDFDownloadTaskOperator( task_id="create_sdf_download_task", body_request=CREATE_SDF_DOWNLOAD_TASK_BODY_REQUEST ) operation_name = '{{ task_instance.xcom_pull("create_sdf_download_task")["name"] }}' # [END howto_google_display_video_create_sdf_download_task_operator]
report_id=report_id, task_id="get_report", bucket_name=BUCKET, report_name="test1.csv", ) # [END howto_google_display_video_getquery_report_operator] # [START howto_google_display_video_deletequery_report_operator] delete_report = GoogleDisplayVideo360DeleteReportOperator( report_id=report_id, task_id="delete_report") # [END howto_google_display_video_deletequery_report_operator] # [START howto_google_display_video_download_line_items_operator] download_line_items = GoogleDisplayVideo360DownloadLineItemsOperator( task_id="download_line_items", request_body=REQUEST_BODY, bucket_name=BUCKET, object_name=OBJECT_NAME, gzip=False, ) # [END howto_google_display_video_download_line_items_operator] # [START howto_google_display_video_upload_line_items_operator] upload_line_items = GoogleDisplayVideo360UploadLineItemsOperator( task_id="upload_line_items", bucket_name=BUCKET, object_name=OBJECT_NAME, ) # [END howto_google_display_video_upload_line_items_operator] create_report >> run_report >> wait_for_report >> get_report >> delete_report