OpenMetadata/ingestion/tests/unit/test_entity_link.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

136 lines
5.1 KiB
Python
Raw Permalink Normal View History

# Copyright 2025 Collate
# Licensed under the Collate Community License, Version 1.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://github.com/open-metadata/OpenMetadata/blob/main/ingestion/LICENSE
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Test Entity Link build behavior
"""
from unittest import TestCase
Fix #14786: Suggestions API (#14821) * Fix #14786: Suggestions API * Handle suggestions in ometa * Minor: Optimise Databricks Client (#14776) * MINOR - Fix SP topology context & Looker usage context (#14816) * MINOR - Fix SP topology context & Looker usage context * MINOR - Fix SP topology context & Looker usage context * Fix tests * Fixes #14598: Fix Tags / Labels ingestion on includeTags as False (#14782) * fix(ui): password error message for char limits (#14808) * fix(ui): password error message for char limits * fix java side code * Fixes #13556: Support for Salesforce table description ingestion (#14733) * ISSUE-13556: Add suport for Salesforce table description ingestion * ISSUE-13556: Remove unnecessary blank line * ISSUE-13556: Fix to get description for each table --------- Co-authored-by: Teddy <teddy.crepineau@gmail.com> * MINOR - Better handling of Ingestion Pipeline Status (#14792) * MINOR - Better handling of Ingestion Pipeline Status * format * format * MINOR: Added table validation for cost analysis data (#14793) * Added validation for cost analysis source * centralized life cycle logic * CYPRESS: simplify side navigation click in cypress (#14818) * simplify side navigation click in cypress * make sidbar item uses common enum * fix cypress failure of outside import * fix(#14326): tier dropdown is not working in advance search (#14780) * improvement in advance search based on custom property * fix a reading undefined property issue * wip: advance search based on tier * some code cleanup and improvement * some fixes * fix: ui flicker when advanceSearched is apply and refresh the page * some cleanup * no need to call customproperty api call, if entity not suppport customProperties * minor change * fix: autocomplete not working in tier search option in advance search modal * added unit test for advance search provider component * some cleanup * added testcase for open modal * added testcase for resetAllFilters method * removed unwanted code * added e2e test for testing tier advance search * fix: e2e search flow for single field * fix: string field not working after giving listValues in TierSearch * fix: group query e2e test fix * used asyncFetch way to get the tierOptions synchronously * some cleanup * remove unwanted lines * some cleanup * fix: selected option show option value instead of option title * fix(minor): update skip icon for executions (#14809) * Fixes #14803: ignore capitalization when confirming deletes (#14804) * ignore case when confirming deletes * Test confirmation of deletes works when case differs Added test case for 'delete' as the confirmation text. * minor(config): update openmetadata-ui code reviewers (#14823) * Add Tests * Add list/accept/reject apis * initial ui changes * localisation * show suggestion for empty description * ui feedbacks * Fix permission check for entities without owner * Fix entityLink and add tests * Add update suggestion WIP * Fix test * Fix PUT and Pagination * Fix styling * update test * Update status * add OM server connection in apps * add permissions check * Fix CI * Remove TODO * Fix feedResourceTest * fix unit tests * add private configs for apps * add private configs for apps * fix update application icons * minor center align icon * add private configs for apps * Format * Fix pydantic gen * Remove token * Update name * Rework private conf * Fix apps * Fix apps * Format * Format * show metapilot only if its installed --------- Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com> Co-authored-by: Mayur Singal <39544459+ulixius9@users.noreply.github.com> Co-authored-by: Ayush Shah <ayush@getcollate.io> Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Co-authored-by: kwgdaig <18678754+kwgdaig@users.noreply.github.com> Co-authored-by: Teddy <teddy.crepineau@gmail.com> Co-authored-by: Onkar Ravgan <onkar.10r@gmail.com> Co-authored-by: Ashish Gupta <ashish@getcollate.io> Co-authored-by: Abhishek Porwal <80886271+Abhishek332@users.noreply.github.com> Co-authored-by: Carlo Q <carlo@machina.bio> Co-authored-by: karanh37 <karanh37@gmail.com>
2024-01-31 18:51:09 -08:00
from metadata.generated.schema.entity.data.dashboard import Dashboard
from metadata.generated.schema.entity.data.table import Table
from metadata.utils import entity_link
Fix #14786: Suggestions API (#14821) * Fix #14786: Suggestions API * Handle suggestions in ometa * Minor: Optimise Databricks Client (#14776) * MINOR - Fix SP topology context & Looker usage context (#14816) * MINOR - Fix SP topology context & Looker usage context * MINOR - Fix SP topology context & Looker usage context * Fix tests * Fixes #14598: Fix Tags / Labels ingestion on includeTags as False (#14782) * fix(ui): password error message for char limits (#14808) * fix(ui): password error message for char limits * fix java side code * Fixes #13556: Support for Salesforce table description ingestion (#14733) * ISSUE-13556: Add suport for Salesforce table description ingestion * ISSUE-13556: Remove unnecessary blank line * ISSUE-13556: Fix to get description for each table --------- Co-authored-by: Teddy <teddy.crepineau@gmail.com> * MINOR - Better handling of Ingestion Pipeline Status (#14792) * MINOR - Better handling of Ingestion Pipeline Status * format * format * MINOR: Added table validation for cost analysis data (#14793) * Added validation for cost analysis source * centralized life cycle logic * CYPRESS: simplify side navigation click in cypress (#14818) * simplify side navigation click in cypress * make sidbar item uses common enum * fix cypress failure of outside import * fix(#14326): tier dropdown is not working in advance search (#14780) * improvement in advance search based on custom property * fix a reading undefined property issue * wip: advance search based on tier * some code cleanup and improvement * some fixes * fix: ui flicker when advanceSearched is apply and refresh the page * some cleanup * no need to call customproperty api call, if entity not suppport customProperties * minor change * fix: autocomplete not working in tier search option in advance search modal * added unit test for advance search provider component * some cleanup * added testcase for open modal * added testcase for resetAllFilters method * removed unwanted code * added e2e test for testing tier advance search * fix: e2e search flow for single field * fix: string field not working after giving listValues in TierSearch * fix: group query e2e test fix * used asyncFetch way to get the tierOptions synchronously * some cleanup * remove unwanted lines * some cleanup * fix: selected option show option value instead of option title * fix(minor): update skip icon for executions (#14809) * Fixes #14803: ignore capitalization when confirming deletes (#14804) * ignore case when confirming deletes * Test confirmation of deletes works when case differs Added test case for 'delete' as the confirmation text. * minor(config): update openmetadata-ui code reviewers (#14823) * Add Tests * Add list/accept/reject apis * initial ui changes * localisation * show suggestion for empty description * ui feedbacks * Fix permission check for entities without owner * Fix entityLink and add tests * Add update suggestion WIP * Fix test * Fix PUT and Pagination * Fix styling * update test * Update status * add OM server connection in apps * add permissions check * Fix CI * Remove TODO * Fix feedResourceTest * fix unit tests * add private configs for apps * add private configs for apps * fix update application icons * minor center align icon * add private configs for apps * Format * Fix pydantic gen * Remove token * Update name * Rework private conf * Fix apps * Fix apps * Format * Format * show metapilot only if its installed --------- Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com> Co-authored-by: Mayur Singal <39544459+ulixius9@users.noreply.github.com> Co-authored-by: Ayush Shah <ayush@getcollate.io> Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Co-authored-by: kwgdaig <18678754+kwgdaig@users.noreply.github.com> Co-authored-by: Teddy <teddy.crepineau@gmail.com> Co-authored-by: Onkar Ravgan <onkar.10r@gmail.com> Co-authored-by: Ashish Gupta <ashish@getcollate.io> Co-authored-by: Abhishek Porwal <80886271+Abhishek332@users.noreply.github.com> Co-authored-by: Carlo Q <carlo@machina.bio> Co-authored-by: karanh37 <karanh37@gmail.com>
2024-01-31 18:51:09 -08:00
from metadata.utils.entity_link import get_entity_link
class TestEntityLink(TestCase):
"""
Validate EntityLink building
"""
def test_split(self):
this = self
class EntityLinkTest:
"""
Test helper class
"""
def __init__(self, entitylink, split_list):
self.entitylink = entitylink
self.split_list = split_list
def validate(self, fn_resp, check_split):
this.assertEqual(fn_resp, check_split)
this.assertEqual(len(fn_resp), len(check_split))
xs = [
EntityLinkTest(
"<#E::table::bigquery_gcp.shopify.raw_product_catalog1>",
["table", "bigquery_gcp.shopify.raw_product_catalog1"],
),
EntityLinkTest(
"<#E::table::bigquery_gcp.shopify.raw_product_catalog2::description>",
["table", "bigquery_gcp.shopify.raw_product_catalog2", "description"],
),
EntityLinkTest(
"<#E::table::bigquery_gcp.shopify.raw_product_catalog3::columns::comment>",
[
"table",
"bigquery_gcp.shopify.raw_product_catalog3",
"columns",
"comment",
],
),
2024-04-11 18:41:59 +05:30
EntityLinkTest(
"<#E::ingestionPipeline::fivetran_gcp.shopify.raw_product_catalog3>",
[
"ingestionPipeline",
"fivetran_gcp.shopify.raw_product_catalog3",
],
),
EntityLinkTest(
"<#E::table::bigquery_gcp.shopify.raw_product_catalog4::columns::comment::description>",
[
"table",
"bigquery_gcp.shopify.raw_product_catalog4",
"columns",
"comment",
"description",
],
),
EntityLinkTest(
"<#E::database::bigquery_gcp.shopify>",
["database", "bigquery_gcp.shopify"],
),
EntityLinkTest(
"<#E::database::bigquery_gcp.shopify::tags>",
["database", "bigquery_gcp.shopify", "tags"],
),
EntityLinkTest(
"<#E::table::bigquery_gcp.shopify.raw-product-catalog5>",
["table", "bigquery_gcp.shopify.raw-product-catalog5"],
),
EntityLinkTest(
'<#E::table::bigquery_gcp.shopify."raw-product-catalog6"::description>',
[
"table",
'bigquery_gcp.shopify."raw-product-catalog6"',
"description",
],
),
EntityLinkTest(
"<#E::table::bigquery_gcp.shopify.raw-product-catalog5::description>",
["table", "bigquery_gcp.shopify.raw-product-catalog5", "description"],
),
EntityLinkTest(
'<#E::table::bigquery_gcp."shop-ify"."raw-product-catalog6">',
["table", 'bigquery_gcp."shop-ify"."raw-product-catalog6"'],
),
EntityLinkTest(
"<#E::table::随机的>",
["table", "随机的"],
),
EntityLinkTest(
'<#E::table::ExampleWithFolder.withfolder.examplewithfolder."folderpath/username.csv">',
[
"table",
'ExampleWithFolder.withfolder.examplewithfolder."folderpath/username.csv"',
],
),
]
for x in xs:
x.validate(entity_link.split(x.entitylink), x.split_list)
Fix #14786: Suggestions API (#14821) * Fix #14786: Suggestions API * Handle suggestions in ometa * Minor: Optimise Databricks Client (#14776) * MINOR - Fix SP topology context & Looker usage context (#14816) * MINOR - Fix SP topology context & Looker usage context * MINOR - Fix SP topology context & Looker usage context * Fix tests * Fixes #14598: Fix Tags / Labels ingestion on includeTags as False (#14782) * fix(ui): password error message for char limits (#14808) * fix(ui): password error message for char limits * fix java side code * Fixes #13556: Support for Salesforce table description ingestion (#14733) * ISSUE-13556: Add suport for Salesforce table description ingestion * ISSUE-13556: Remove unnecessary blank line * ISSUE-13556: Fix to get description for each table --------- Co-authored-by: Teddy <teddy.crepineau@gmail.com> * MINOR - Better handling of Ingestion Pipeline Status (#14792) * MINOR - Better handling of Ingestion Pipeline Status * format * format * MINOR: Added table validation for cost analysis data (#14793) * Added validation for cost analysis source * centralized life cycle logic * CYPRESS: simplify side navigation click in cypress (#14818) * simplify side navigation click in cypress * make sidbar item uses common enum * fix cypress failure of outside import * fix(#14326): tier dropdown is not working in advance search (#14780) * improvement in advance search based on custom property * fix a reading undefined property issue * wip: advance search based on tier * some code cleanup and improvement * some fixes * fix: ui flicker when advanceSearched is apply and refresh the page * some cleanup * no need to call customproperty api call, if entity not suppport customProperties * minor change * fix: autocomplete not working in tier search option in advance search modal * added unit test for advance search provider component * some cleanup * added testcase for open modal * added testcase for resetAllFilters method * removed unwanted code * added e2e test for testing tier advance search * fix: e2e search flow for single field * fix: string field not working after giving listValues in TierSearch * fix: group query e2e test fix * used asyncFetch way to get the tierOptions synchronously * some cleanup * remove unwanted lines * some cleanup * fix: selected option show option value instead of option title * fix(minor): update skip icon for executions (#14809) * Fixes #14803: ignore capitalization when confirming deletes (#14804) * ignore case when confirming deletes * Test confirmation of deletes works when case differs Added test case for 'delete' as the confirmation text. * minor(config): update openmetadata-ui code reviewers (#14823) * Add Tests * Add list/accept/reject apis * initial ui changes * localisation * show suggestion for empty description * ui feedbacks * Fix permission check for entities without owner * Fix entityLink and add tests * Add update suggestion WIP * Fix test * Fix PUT and Pagination * Fix styling * update test * Update status * add OM server connection in apps * add permissions check * Fix CI * Remove TODO * Fix feedResourceTest * fix unit tests * add private configs for apps * add private configs for apps * fix update application icons * minor center align icon * add private configs for apps * Format * Fix pydantic gen * Remove token * Update name * Rework private conf * Fix apps * Fix apps * Format * Format * show metapilot only if its installed --------- Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com> Co-authored-by: Mayur Singal <39544459+ulixius9@users.noreply.github.com> Co-authored-by: Ayush Shah <ayush@getcollate.io> Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Co-authored-by: kwgdaig <18678754+kwgdaig@users.noreply.github.com> Co-authored-by: Teddy <teddy.crepineau@gmail.com> Co-authored-by: Onkar Ravgan <onkar.10r@gmail.com> Co-authored-by: Ashish Gupta <ashish@getcollate.io> Co-authored-by: Abhishek Porwal <80886271+Abhishek332@users.noreply.github.com> Co-authored-by: Carlo Q <carlo@machina.bio> Co-authored-by: karanh37 <karanh37@gmail.com>
2024-01-31 18:51:09 -08:00
def test_get_entity_link(self):
"""We can get entity link for different entities"""
table_link = get_entity_link(Table, fqn="service.db.schema.table")
self.assertEqual(table_link, "<#E::table::service.db.schema.table>")
dashboard_link = get_entity_link(Dashboard, fqn="service.dashboard")
self.assertEqual(dashboard_link, "<#E::dashboard::service.dashboard>")
column_link = get_entity_link(
Table, fqn="service.db.schema.table", column_name="col"
)
self.assertEqual(
column_link, "<#E::table::service.db.schema.table::columns::col>"
)