def test_create_inspect_template(self, mock_hook): mock_hook.return_value.create_inspect_template.return_value = {} operator = CloudDLPCreateInspectTemplateOperator( organization_id=ORGANIZATION_ID, task_id="id") operator.execute(context=None) mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID) mock_hook.return_value.create_inspect_template.assert_called_once_with( organization_id=ORGANIZATION_ID, project_id=None, inspect_template=None, template_id=None, retry=None, timeout=None, metadata=None, )
OUTPUT_FILENAME = "test.txt" OBJECT_GCS_URI = os.path.join(OUTPUT_BUCKET, "tmp") OBJECT_GCS_OUTPUT_URI = os.path.join(OUTPUT_BUCKET, "tmp", OUTPUT_FILENAME) with models.DAG( "example_gcp_dlp", schedule_interval=None, # Override to match your needs start_date=days_ago(1), tags=['example'], ) as dag1: # [START howto_operator_dlp_create_inspect_template] create_template = CloudDLPCreateInspectTemplateOperator( project_id=GCP_PROJECT, inspect_template=INSPECT_TEMPLATE, template_id=TEMPLATE_ID, task_id="create_template", do_xcom_push=True, ) # [END howto_operator_dlp_create_inspect_template] # [START howto_operator_dlp_use_inspect_template] inspect_content = CloudDLPInspectContentOperator( task_id="inpsect_content", project_id=GCP_PROJECT, item=ITEM, inspect_template_name= "{{ task_instance.xcom_pull('create_template', key='return_value')['name'] }}", ) # [END howto_operator_dlp_use_inspect_template]