|
1 | 1 | # SPDX-License-Identifier: Apache-2.0
|
2 | 2 | # Copyright 2022 Atlan Pte. Ltd.
|
| 3 | +import logging |
3 | 4 | import time
|
4 | 5 | from typing import Generator, List, Optional
|
5 | 6 |
|
|
8 | 9 | from pyatlan.cache.custom_metadata_cache import CustomMetadataCache
|
9 | 10 | from pyatlan.client.atlan import AtlanClient
|
10 | 11 | from pyatlan.error import NotFoundError
|
11 |
| -from pyatlan.model.assets import AtlasGlossary, AtlasGlossaryTerm, Table |
| 12 | +from pyatlan.model.assets import ( |
| 13 | + AtlasGlossary, |
| 14 | + AtlasGlossaryTerm, |
| 15 | + Badge, |
| 16 | + BadgeCondition, |
| 17 | + Table, |
| 18 | +) |
12 | 19 | from pyatlan.model.core import CustomMetadata, to_snake_case
|
13 |
| -from pyatlan.model.enums import AtlanCustomAttributePrimitiveType, AtlanTypeCategory |
| 20 | +from pyatlan.model.enums import ( |
| 21 | + AtlanCustomAttributePrimitiveType, |
| 22 | + AtlanTypeCategory, |
| 23 | + BadgeComparisonOperator, |
| 24 | + BadgeConditionColor, |
| 25 | +) |
14 | 26 | from pyatlan.model.search import DSL, Bool, Exists, IndexSearchRequest, Term
|
15 | 27 | from pyatlan.model.typedef import AttributeDef, CustomMetadataDef, EnumDef
|
16 | 28 | from tests.integration.client import delete_asset
|
17 | 29 | from tests.integration.glossary_test import create_glossary, create_term
|
18 | 30 |
|
19 |
| -import logging |
20 |
| - |
21 | 31 | LOGGER = logging.getLogger(__name__)
|
22 | 32 |
|
23 | 33 | PREFIX = "psdk-"
|
@@ -287,7 +297,8 @@ def cm_dq(
|
287 | 297 | client,
|
288 | 298 | name=CM_QUALITY,
|
289 | 299 | attribute_defs=attribute_defs,
|
290 |
| - logo="https://github.com/great-expectations/great_expectations/raw/develop/docs/docusaurus/static/img/gx-mark-160.png", |
| 300 | + logo="https://github.com/great-expectations/great_expectations/raw/develop/docs/docusaurus/static/img/" |
| 301 | + "gx-mark-160.png", |
291 | 302 | locked=False,
|
292 | 303 | )
|
293 | 304 | yield cm
|
@@ -512,7 +523,6 @@ def test_search_by_specific_accountable(
|
512 | 523 | anchor = t.attributes.anchor
|
513 | 524 | assert anchor
|
514 | 525 | assert anchor.name == glossary.name
|
515 |
| - return t |
516 | 526 |
|
517 | 527 |
|
518 | 528 | @pytest.mark.order(
|
@@ -879,3 +889,36 @@ def _validate_raci_structure(
|
879 | 889 | if total_expected > 4:
|
880 | 890 | return attributes[total_expected - 1]
|
881 | 891 | return None
|
| 892 | + |
| 893 | + |
| 894 | +def test_add_badge_cm_dq( |
| 895 | + client: AtlanClient, |
| 896 | + cm_dq: CustomMetadataDef, |
| 897 | +): |
| 898 | + badge = Badge.create( |
| 899 | + name=CM_ATTR_QUALITY_COUNT, |
| 900 | + cm_name=CM_QUALITY, |
| 901 | + cm_attribute=CM_ATTR_QUALITY_COUNT_RENAMED, |
| 902 | + badge_conditions=[ |
| 903 | + BadgeCondition.create( |
| 904 | + badge_condition_operator=BadgeComparisonOperator.GTE, |
| 905 | + badge_condition_value="5", |
| 906 | + badge_condition_colorhex=BadgeConditionColor.GREEN, |
| 907 | + ), |
| 908 | + BadgeCondition.create( |
| 909 | + badge_condition_operator=BadgeComparisonOperator.LT, |
| 910 | + badge_condition_value="5", |
| 911 | + badge_condition_colorhex=BadgeConditionColor.YELLOW, |
| 912 | + ), |
| 913 | + BadgeCondition.create( |
| 914 | + badge_condition_operator=BadgeComparisonOperator.LTE, |
| 915 | + badge_condition_value="2", |
| 916 | + badge_condition_colorhex=BadgeConditionColor.RED, |
| 917 | + ), |
| 918 | + ], |
| 919 | + ) |
| 920 | + badge.user_description = "How many data quality checks ran against this asset." |
| 921 | + response = client.upsert(badge) |
| 922 | + assert (badges := response.assets_created(asset_type=Badge)) |
| 923 | + assert len(badges) == 1 |
| 924 | + client.purge_entity_by_guid(badges[0].guid) |
0 commit comments