Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINOR: Update Glossary Term tests #18698

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions ingestion/tests/integration/ometa/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@

import pytest

from metadata.generated.schema.api.data.createGlossary import CreateGlossaryRequest
from metadata.generated.schema.api.data.createGlossaryTerm import (
CreateGlossaryTermRequest,
)
from metadata.generated.schema.api.teams.createUser import CreateUserRequest
from metadata.generated.schema.entity.data.glossary import Glossary
from metadata.generated.schema.entity.data.glossaryTerm import GlossaryTerm
from metadata.generated.schema.entity.services.connections.database.common.basicAuth import (
BasicAuth,
)
from metadata.generated.schema.entity.services.connections.database.mysqlConnection import (
MysqlConnection,
)
from metadata.generated.schema.entity.services.databaseService import DatabaseService
from metadata.generated.schema.entity.teams.user import User
from metadata.workflow.metadata import MetadataWorkflow

from ..containers import MySqlContainerConfigs, get_mysql_container
Expand Down Expand Up @@ -78,3 +86,61 @@ def workflow(metadata, service, mysql_container):
)
workflow_config["ingestionPipelineFQN"] = f"{service_name}.ingestion"
return MetadataWorkflow.create(workflow_config)


@pytest.fixture
def create_glossary(metadata):
glossaries = []

def _create_glossary(create_request: CreateGlossaryRequest):
glossary = metadata.create_or_update(data=create_request)
glossaries.append(glossary)
return glossary

def teardown():
for glossary in glossaries:
metadata.delete(entity=Glossary, entity_id=glossary.id, hard_delete=True)

yield _create_glossary

teardown()


@pytest.fixture
def create_glossary_term(metadata, create_glossary):
glossary_terms = []

def _create_glossary_term(create_request: CreateGlossaryTermRequest):
glossary_term = metadata.create_or_update(data=create_request)

glossary_terms.append(glossary_term)
return glossary_term

def teardown():
glossary_terms.reverse()
for glossary_term in glossary_terms:
metadata.delete(
entity=GlossaryTerm, entity_id=glossary_term.id, hard_delete=True
)

yield _create_glossary_term

teardown()


@pytest.fixture
def create_user(metadata, request):
users = []

def _create_user(create_request: CreateUserRequest):
user = metadata.create_or_update(data=create_request)
users.append(user)
return user

def teardown():
for user in users:
metadata.delete(entity=User, entity_id=user.id, hard_delete=True)

request.addfinalizer(teardown)

return _create_user
Loading
Loading