def test_inspect_content(self, mock_hook): mock_hook.return_value.inspect_content.return_value = {} operator = CloudDLPInspectContentOperator(project_id=PROJECT_ID, task_id="id") operator.execute(context=None) mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID) mock_hook.return_value.inspect_content.assert_called_once_with( project_id=PROJECT_ID, inspect_config=None, item=None, inspect_template_name=None, retry=None, timeout=None, metadata=None, )
) 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] # [START howto_operator_dlp_delete_inspect_template] delete_template = CloudDLPDeleteInspectTemplateOperator( task_id="delete_template", template_id=TEMPLATE_ID, project_id=GCP_PROJECT, ) # [END howto_operator_dlp_delete_inspect_template] create_template >> inspect_content >> delete_template