Beispiel #1
0
 def test_assert_valid_hook_call(self, mock_hook) -> None:
     task = CloudDataCatalogSearchCatalogOperator(
         task_id="task_id",
         scope=TEST_SCOPE,
         query=TEST_QUERY,
         page_size=TEST_PAGE_SIZE,
         order_by=TEST_ORDER_BY,
         retry=TEST_RETRY,
         timeout=TEST_TIMEOUT,
         metadata=TEST_METADATA,
         gcp_conn_id=TEST_GCP_CONN_ID,
         impersonation_chain=TEST_IMPERSONATION_CHAIN,
     )
     task.execute(context=mock.MagicMock())
     mock_hook.assert_called_once_with(
         gcp_conn_id=TEST_GCP_CONN_ID,
         impersonation_chain=TEST_IMPERSONATION_CHAIN,
     )
     mock_hook.return_value.search_catalog.assert_called_once_with(
         scope=TEST_SCOPE,
         query=TEST_QUERY,
         page_size=TEST_PAGE_SIZE,
         order_by=TEST_ORDER_BY,
         retry=TEST_RETRY,
         timeout=TEST_TIMEOUT,
         metadata=TEST_METADATA,
     )
    # Rename
    # [START howto_operator_gcp_datacatalog_rename_tag_template_field]
    rename_tag_template_field = CloudDataCatalogRenameTagTemplateFieldOperator(
        task_id="rename_tag_template_field",
        location=LOCATION,
        tag_template=TEMPLATE_ID,
        field=FIELD_NAME_1,
        new_tag_template_field_id=FIELD_NAME_3,
    )
    # [END howto_operator_gcp_datacatalog_rename_tag_template_field]

    # Search
    # [START howto_operator_gcp_datacatalog_search_catalog]
    search_catalog = CloudDataCatalogSearchCatalogOperator(
        task_id="search_catalog",
        scope={"include_project_ids": [PROJECT_ID]},
        query=f"projectid:{PROJECT_ID}")
    # [END howto_operator_gcp_datacatalog_search_catalog]

    # [START howto_operator_gcp_datacatalog_search_catalog_result]
    search_catalog_result = BashOperator(
        task_id="search_catalog_result",
        bash_command="echo \"{{ task_instance.xcom_pull('search_catalog') }}\"",
    )
    # [END howto_operator_gcp_datacatalog_search_catalog_result]

    # Update
    # [START howto_operator_gcp_datacatalog_update_entry]
    update_entry = CloudDataCatalogUpdateEntryOperator(
        task_id="update_entry",
        entry={"display_name": "New Wizard"},