OpenMetadata/ingestion/tests/integration/ometa/test_ometa_suggestion_api.py

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

198 lines
6.5 KiB
Python
Raw Normal View History

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
# 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.
"""
OpenMetadata high-level API Suggestion test
"""
from unittest import TestCase
from metadata.generated.schema.api.feed.createSuggestion import CreateSuggestionRequest
from metadata.generated.schema.entity.data.database import Database
from metadata.generated.schema.entity.data.databaseSchema import DatabaseSchema
from metadata.generated.schema.entity.data.table import Table
from metadata.generated.schema.entity.feed.suggestion import Suggestion, SuggestionType
from metadata.generated.schema.entity.services.databaseService import DatabaseService
from metadata.generated.schema.entity.teams.user import User
from metadata.generated.schema.type.basic import EntityLink
from metadata.generated.schema.type.tagLabel import (
LabelType,
State,
TagLabel,
TagSource,
)
from metadata.utils.entity_link import get_entity_link
from ..integration_base import (
generate_name,
get_create_entity,
get_create_service,
int_admin_ometa,
)
class OMetaSuggestionTest(TestCase):
"""
Run this integration test with the local API available
Install the ingestion package before running the tests
"""
metadata = int_admin_ometa()
service_name = generate_name()
db_name = generate_name()
schema_name = generate_name()
table_name = generate_name()
@classmethod
def setUpClass(cls) -> None:
"""
Prepare ingredients: Pipeline Entity
"""
create_service = get_create_service(
entity=DatabaseService, name=cls.service_name
)
cls.metadata.create_or_update(create_service)
create_database = get_create_entity(
entity=Database, name=cls.schema_name, reference=cls.service_name.__root__
)
cls.database: Database = cls.metadata.create_or_update(create_database)
create_schema = get_create_entity(
entity=DatabaseSchema,
name=cls.schema_name,
reference=cls.database.fullyQualifiedName.__root__,
)
cls.schema: DatabaseSchema = cls.metadata.create_or_update(create_schema)
create_table = get_create_entity(
entity=Table,
name=cls.table_name,
reference=cls.schema.fullyQualifiedName.__root__,
)
cls.table: Table = cls.metadata.create_or_update(create_table)
@classmethod
def tearDownClass(cls) -> None:
"""
Clean up
"""
service_id = str(
cls.metadata.get_by_name(
entity=DatabaseService, fqn=cls.service_name.__root__
).id.__root__
)
cls.metadata.delete(
entity=DatabaseService,
entity_id=service_id,
recursive=True,
hard_delete=True,
)
def test_create_description_suggestion(self):
"""We can create a suggestion"""
suggestion_request = CreateSuggestionRequest(
description="something",
type=SuggestionType.SuggestDescription,
entityLink=EntityLink(
__root__=get_entity_link(
Table, fqn=self.table.fullyQualifiedName.__root__
)
),
)
# Suggestions only support POST (not PUT)
self.metadata.create(suggestion_request)
def test_create_tag_suggestion(self):
"""We can create a suggestion"""
suggestion_request = CreateSuggestionRequest(
tagLabels=[
TagLabel(
tagFQN="PII.Sensitive",
labelType=LabelType.Automated,
state=State.Suggested.value,
source=TagSource.Classification,
)
],
type=SuggestionType.SuggestTagLabel,
entityLink=EntityLink(
__root__=get_entity_link(
Table, fqn=self.table.fullyQualifiedName.__root__
)
),
)
# Suggestions only support POST (not PUT)
self.metadata.create(suggestion_request)
def test_list(self):
"""List filtering by creator"""
admin_user: User = self.metadata.get_by_name(
entity=User, fqn="admin", nullable=False
)
create_table = get_create_entity(
entity=Table,
reference=self.schema.fullyQualifiedName.__root__,
)
table: Table = self.metadata.create_or_update(create_table)
suggestion_request = CreateSuggestionRequest(
description="something",
type=SuggestionType.SuggestDescription,
entityLink=EntityLink(
__root__=get_entity_link(Table, fqn=table.fullyQualifiedName.__root__)
),
)
# Suggestions only support POST (not PUT)
self.metadata.create(suggestion_request)
suggestions = self.metadata.list_all_entities(
entity=Suggestion,
params={
"entityFQN": table.fullyQualifiedName.__root__,
"userId": str(admin_user.id.__root__),
},
)
self.assertEqual(len(list(suggestions)), 1)
def test_update_suggestion(self):
"""Update an existing suggestion"""
create_table = get_create_entity(
entity=Table,
name=self.schema_name,
reference=self.schema.fullyQualifiedName.__root__,
)
table: Table = self.metadata.create_or_update(create_table)
suggestion_request = CreateSuggestionRequest(
description="something",
type=SuggestionType.SuggestDescription,
entityLink=EntityLink(
__root__=get_entity_link(Table, fqn=table.fullyQualifiedName.__root__)
),
)
# Suggestions only support POST (not PUT)
res: Suggestion = self.metadata.create(suggestion_request)
self.assertEqual(res.description, "something")
res.description = "new"
new = self.metadata.update_suggestion(res)
self.assertEqual(new.description, "new")