mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-07 00:58:46 +00:00

* Change entityReference to entity name or fullyQualifiedName * Change backend code and tests to use FQN * UI change for using fqns instead of EntityReference * Ingestion framework changes for using fqns instead of EntityReference * Fix test failures * Fixed python tests and sample data new * fix: minor ui changes for fqn * Fixed python integration tests * Fixed superset tests * fix UI tests * fix type issue * fix cypress * fix name for testcase --------- Co-authored-by: Onkar Ravgan <onkar.10r@gmail.com> Co-authored-by: karanh37 <karanh37@gmail.com> Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
67 lines
2.4 KiB
Python
67 lines
2.4 KiB
Python
# Copyright 2021 Collate
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
# 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 helpers
|
|
"""
|
|
import uuid
|
|
from unittest import TestCase
|
|
|
|
from metadata.generated.schema.entity.data.table import Column, DataType, Table
|
|
from metadata.utils.helpers import (
|
|
find_column_in_table,
|
|
find_column_in_table_with_index,
|
|
find_in_iter,
|
|
)
|
|
|
|
|
|
class HelpersTest(TestCase):
|
|
def test_find_in_iter(self):
|
|
"""We can find elements within a list"""
|
|
iter_ = ("A", "B", "C")
|
|
|
|
found = find_in_iter(element="B", container=iter_)
|
|
self.assertEqual("B", found)
|
|
|
|
not_found = find_in_iter(element="random", container=iter_)
|
|
self.assertIsNone(not_found)
|
|
|
|
def test_find_column_in_table(self):
|
|
"""Check we can find a column inside a table"""
|
|
|
|
table = Table(
|
|
id=uuid.uuid4(),
|
|
name="test",
|
|
databaseSchema="test-service-table.test-db.test-schema",
|
|
fullyQualifiedName="test-service-table.test-db.test-schema.test",
|
|
columns=[
|
|
Column(name="id", dataType=DataType.BIGINT),
|
|
Column(name="hello", dataType=DataType.BIGINT),
|
|
Column(name="foo", dataType=DataType.BIGINT),
|
|
Column(name="bar", dataType=DataType.BIGINT),
|
|
],
|
|
)
|
|
|
|
col = find_column_in_table(column_name="foo", table=table)
|
|
self.assertEqual(col, Column(name="foo", dataType=DataType.BIGINT))
|
|
|
|
not_found = find_column_in_table(column_name="random", table=table)
|
|
self.assertIsNone(not_found)
|
|
|
|
idx, col = find_column_in_table_with_index(column_name="foo", table=table)
|
|
self.assertEqual(col, Column(name="foo", dataType=DataType.BIGINT))
|
|
self.assertEqual(idx, 2)
|
|
|
|
not_found_col, not_found_idx = find_column_in_table_with_index(
|
|
column_name="random", table=table
|
|
)
|
|
self.assertIsNone(not_found)
|
|
self.assertIsNone(not_found_idx)
|