Skip to content

Commit 55581a7

Browse files
authored
Merge pull request #864 from atlanhq/PART-548
test: add integration tests for STRING vs RICH_TEXT CM attribute dist…
2 parents 258c41e + 5b10143 commit 55581a7

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

tests/integration/custom_metadata_test.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
CM_ATTR_RICH_TEXT_CONTENT = "Rich Content"
7272
CM_ATTR_RICH_TEXT_DESCRIPTION = "Rich Description"
7373

74+
CM_STRING_VS_RICH_TEXT = f"{MODULE_NAME}_STR_RT"
75+
CM_ATTR_PLAIN_STRING = "Plain String"
76+
CM_ATTR_RICH_STRING = "Rich String"
77+
7478
DQ_ENUM = f"{MODULE_NAME}_DataQualityType"
7579
DQ_TYPE_LIST = [
7680
"Accuracy",
@@ -201,6 +205,7 @@ def test_cm_ipr(cm_ipr: CustomMetadataDef, limit_attribute_applicability_kwargs)
201205
assert one_with_limited.description == ATTRIBUTE_DESCRIPTION
202206
assert one_with_limited.name != CM_ATTR_IPR_LICENSE
203207
assert one_with_limited.type_name == AtlanCustomAttributePrimitiveType.STRING.value
208+
assert one_with_limited.options.is_rich_text is False
204209
assert not one_with_limited.options.multi_value_select
205210
options = one_with_limited.options
206211
for attribute in limit_attribute_applicability_kwargs.keys():
@@ -310,6 +315,7 @@ def test_cm_raci(
310315
assert one.name != CM_ATTR_RACI_ACCOUNTABLE
311316
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
312317
assert one.options
318+
assert one.options.is_rich_text is False
313319
assert not one.options.multi_value_select
314320
one = attributes[2]
315321
assert one.display_name == CM_ATTR_RACI_CONSULTED
@@ -330,6 +336,7 @@ def test_cm_raci(
330336
assert one.name != CM_ATTR_RACI_EXTRA
331337
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
332338
assert one.options
339+
assert one.options.is_rich_text is False
333340
assert not one.options.multi_value_select
334341

335342

@@ -578,6 +585,58 @@ def test_rich_text_cannot_be_multi_valued(client: AtlanClient):
578585
assert "ATLAN-PYTHON-400-076" in str(error)
579586

580587

588+
@pytest.fixture(scope="module")
589+
def cm_string_vs_rich_text(
590+
client: AtlanClient,
591+
) -> Generator[CustomMetadataDef, None, None]:
592+
attribute_defs = [
593+
AttributeDef.create(
594+
client=client,
595+
display_name=CM_ATTR_PLAIN_STRING,
596+
attribute_type=AtlanCustomAttributePrimitiveType.STRING,
597+
),
598+
AttributeDef.create(
599+
client=client,
600+
display_name=CM_ATTR_RICH_STRING,
601+
attribute_type=AtlanCustomAttributePrimitiveType.RICH_TEXT,
602+
),
603+
]
604+
cm = create_custom_metadata(
605+
client,
606+
name=CM_STRING_VS_RICH_TEXT,
607+
attribute_defs=attribute_defs,
608+
logo="🔤",
609+
locked=False,
610+
)
611+
yield cm
612+
wait_for_successful_custometadatadef_purge(CM_STRING_VS_RICH_TEXT, client=client)
613+
614+
615+
def test_string_vs_rich_text(cm_string_vs_rich_text: CustomMetadataDef):
616+
"""Test that STRING and RICH_TEXT produce distinct CM attributes."""
617+
attributes = cm_string_vs_rich_text.attribute_defs
618+
assert attributes
619+
assert len(attributes) == 2
620+
621+
# STRING attribute: is_rich_text must be False
622+
plain = attributes[0]
623+
assert plain.display_name == CM_ATTR_PLAIN_STRING
624+
assert plain.type_name == AtlanCustomAttributePrimitiveType.STRING.value
625+
assert plain.options
626+
assert plain.options.is_rich_text is False
627+
assert (
628+
plain.options.primitive_type == AtlanCustomAttributePrimitiveType.STRING.value
629+
)
630+
631+
# RICH_TEXT attribute: is_rich_text must be True
632+
rich = attributes[1]
633+
assert rich.display_name == CM_ATTR_RICH_STRING
634+
assert rich.type_name == AtlanCustomAttributePrimitiveType.STRING.value
635+
assert rich.options
636+
assert rich.options.is_rich_text is True
637+
assert rich.options.primitive_type == AtlanCustomAttributePrimitiveType.STRING.value
638+
639+
581640
@pytest.fixture(scope="module")
582641
def glossary(
583642
client: AtlanClient,

tests_v9/integration/custom_metadata_test.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
CM_ATTR_RICH_TEXT_CONTENT = "Rich Content"
7272
CM_ATTR_RICH_TEXT_DESCRIPTION = "Rich Description"
7373

74+
CM_STRING_VS_RICH_TEXT = f"{MODULE_NAME}_STR_RT"
75+
CM_ATTR_PLAIN_STRING = "Plain String"
76+
CM_ATTR_RICH_STRING = "Rich String"
77+
7478
DQ_ENUM = f"{MODULE_NAME}_DataQualityType"
7579
DQ_TYPE_LIST = [
7680
"Accuracy",
@@ -201,6 +205,7 @@ def test_cm_ipr(cm_ipr: CustomMetadataDef, limit_attribute_applicability_kwargs)
201205
assert one_with_limited.description == ATTRIBUTE_DESCRIPTION
202206
assert one_with_limited.name != CM_ATTR_IPR_LICENSE
203207
assert one_with_limited.type_name == AtlanCustomAttributePrimitiveType.STRING.value
208+
assert one_with_limited.options.is_rich_text is False
204209
assert not one_with_limited.options.multi_value_select
205210
options = one_with_limited.options
206211
for attribute in limit_attribute_applicability_kwargs.keys():
@@ -310,6 +315,7 @@ def test_cm_raci(
310315
assert one.name != CM_ATTR_RACI_ACCOUNTABLE
311316
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
312317
assert one.options
318+
assert one.options.is_rich_text is False
313319
assert not one.options.multi_value_select
314320
one = attributes[2]
315321
assert one.display_name == CM_ATTR_RACI_CONSULTED
@@ -330,6 +336,7 @@ def test_cm_raci(
330336
assert one.name != CM_ATTR_RACI_EXTRA
331337
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
332338
assert one.options
339+
assert one.options.is_rich_text is False
333340
assert not one.options.multi_value_select
334341

335342

@@ -575,6 +582,58 @@ def test_rich_text_cannot_be_multi_valued(client: AtlanClient):
575582
assert "ATLAN-PYTHON-400-076" in str(error)
576583

577584

585+
@pytest.fixture(scope="module")
586+
def cm_string_vs_rich_text(
587+
client: AtlanClient,
588+
) -> Generator[CustomMetadataDef, None, None]:
589+
attribute_defs = [
590+
AttributeDef.creator(
591+
client=client,
592+
display_name=CM_ATTR_PLAIN_STRING,
593+
attribute_type=AtlanCustomAttributePrimitiveType.STRING,
594+
),
595+
AttributeDef.creator(
596+
client=client,
597+
display_name=CM_ATTR_RICH_STRING,
598+
attribute_type=AtlanCustomAttributePrimitiveType.RICH_TEXT,
599+
),
600+
]
601+
cm = create_custom_metadata(
602+
client,
603+
name=CM_STRING_VS_RICH_TEXT,
604+
attribute_defs=attribute_defs,
605+
logo="🔤",
606+
locked=False,
607+
)
608+
yield cm
609+
wait_for_successful_custometadatadef_purge(CM_STRING_VS_RICH_TEXT, client=client)
610+
611+
612+
def test_string_vs_rich_text(cm_string_vs_rich_text: CustomMetadataDef):
613+
"""Test that STRING and RICH_TEXT produce distinct CM attributes."""
614+
attributes = cm_string_vs_rich_text.attribute_defs
615+
assert attributes
616+
assert len(attributes) == 2
617+
618+
# STRING attribute: is_rich_text must be False
619+
plain = attributes[0]
620+
assert plain.display_name == CM_ATTR_PLAIN_STRING
621+
assert plain.type_name == AtlanCustomAttributePrimitiveType.STRING.value
622+
assert plain.options
623+
assert plain.options.is_rich_text is False
624+
assert (
625+
plain.options.primitive_type == AtlanCustomAttributePrimitiveType.STRING.value
626+
)
627+
628+
# RICH_TEXT attribute: is_rich_text must be True
629+
rich = attributes[1]
630+
assert rich.display_name == CM_ATTR_RICH_STRING
631+
assert rich.type_name == AtlanCustomAttributePrimitiveType.STRING.value
632+
assert rich.options
633+
assert rich.options.is_rich_text is True
634+
assert rich.options.primitive_type == AtlanCustomAttributePrimitiveType.STRING.value
635+
636+
578637
@pytest.fixture(scope="module")
579638
def glossary(
580639
client: AtlanClient,

0 commit comments

Comments
 (0)