Skip to content

Commit

Permalink
Merge pull request #429 from atlanhq/ft-782
Browse files Browse the repository at this point in the history
FT-782 Add method to wait for custom metadata type def to complete
  • Loading branch information
Aryamanz29 authored Nov 25, 2024
2 parents 1ad4b0e + c3db9c7 commit c83eaf1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
12 changes: 8 additions & 4 deletions tests/integration/custom_metadata_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
from tests.integration.admin_test import create_group, delete_group
from tests.integration.client import TestId, delete_asset
from tests.integration.glossary_test import create_glossary, create_term
from tests.integration.utils import (
wait_for_successful_custometadatadef_purge,
wait_for_successful_enumadef_purge,
)

MODULE_NAME = TestId.make_unique("CM")

Expand Down Expand Up @@ -162,7 +166,7 @@ def cm_ipr(
client, name=CM_IPR, attribute_defs=attribute_defs, logo="⚖️", locked=True
)
yield cm
client.typedef.purge(CM_IPR, CustomMetadataDef)
wait_for_successful_custometadatadef_purge(CM_IPR, client=client)


def test_cm_ipr(cm_ipr: CustomMetadataDef, limit_attribute_applicability_kwargs):
Expand Down Expand Up @@ -254,7 +258,7 @@ def cm_raci(
locked=False,
)
yield cm
client.typedef.purge(CM_RACI, CustomMetadataDef)
wait_for_successful_custometadatadef_purge(CM_RACI, client=client)


def test_cm_raci(
Expand Down Expand Up @@ -309,7 +313,7 @@ def cm_enum(
) -> Generator[EnumDef, None, None]:
enum_def = create_enum(client, name=DQ_ENUM, values=DQ_TYPE_LIST)
yield enum_def
client.typedef.purge(DQ_ENUM, EnumDef)
wait_for_successful_enumadef_purge(DQ_ENUM, client=client)


def test_cm_enum(
Expand Down Expand Up @@ -402,7 +406,7 @@ def cm_dq(
locked=True,
)
yield cm
client.typedef.purge(CM_QUALITY, CustomMetadataDef)
wait_for_successful_custometadatadef_purge(CM_QUALITY, client=client)


def test_cm_dq(
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/data_mesh_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from pyatlan.model.typedef import AttributeDef, CustomMetadataDef
from tests.integration.client import TestId, delete_asset
from tests.integration.custom_metadata_test import create_custom_metadata
from tests.integration.utils import block
from tests.integration.utils import block, wait_for_successful_custometadatadef_purge

DATA_PRODUCT_ASSETS_PLAYBOOK_FILTER = (
'{"condition":"AND","isGroupLocked":false,"rules":[]}'
Expand Down Expand Up @@ -230,7 +230,7 @@ def data_domain_cm(
client, name=DD_CM, attribute_defs=attribute_defs, logo="📦", locked=True
)
yield dd_cm
client.typedef.purge(DD_CM, CustomMetadataDef)
wait_for_successful_custometadatadef_purge(DD_CM, client=client)


def test_data_domain_cm(data_domain_cm: CustomMetadataDef):
Expand Down
20 changes: 19 additions & 1 deletion tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pyatlan.model.assets import Asset
from pyatlan.model.enums import EntityStatus
from pyatlan.model.response import AssetMutationResponse
from pyatlan.model.typedef import AtlanTagDef
from pyatlan.model.typedef import AtlanTagDef, CustomMetadataDef, EnumDef


def block(
Expand Down Expand Up @@ -56,3 +56,21 @@ def retrieve_and_check_assets(
)
def wait_for_successful_tagdef_purge(name: str, client: AtlanClient):
client.typedef.purge(name, typedef_type=AtlanTagDef)


@retry(
retry=retry_if_exception_type(AtlanError),
wait=wait_random_exponential(multiplier=1, max=5),
stop=stop_after_attempt(3),
)
def wait_for_successful_custometadatadef_purge(name: str, client: AtlanClient):
client.typedef.purge(name, typedef_type=CustomMetadataDef)


@retry(
retry=retry_if_exception_type(AtlanError),
wait=wait_random_exponential(multiplier=1, max=5),
stop=stop_after_attempt(3),
)
def wait_for_successful_enumadef_purge(name: str, client: AtlanClient):
client.typedef.purge(name, typedef_type=EnumDef)

0 comments on commit c83eaf1

Please sign in to comment.