Skip to content

Commit b5e1018

Browse files
committed
adding unit tests
1 parent e6c0dcc commit b5e1018

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/unit/test_typedef_model.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from pyatlan.model.typedef import (
1717
AtlanTagDef,
1818
AttributeDef,
19+
Cardinality,
1920
CustomMetadataDef,
2021
EntityDef,
2122
EnumDef,
@@ -443,3 +444,33 @@ def test_attribute_create_with_limited_applicability(self, client: AtlanClient):
443444
assert getattr(options, attribute) == json.dumps(
444445
list(applicable_kwargs.get(attribute)) # type: ignore[arg-type]
445446
)
447+
448+
def test_multi_value_select_setter_condition(self, client: AtlanClient):
449+
with patch("pyatlan.model.typedef._get_all_qualified_names") as mock_get_qa:
450+
mock_get_qa.return_value = set()
451+
452+
attr_def = AttributeDef.create(
453+
client=client,
454+
display_name="Test Attribute",
455+
attribute_type=AtlanCustomAttributePrimitiveType.STRING,
456+
)
457+
458+
assert attr_def.options is not None
459+
assert attr_def.options.multi_value_select is False
460+
assert attr_def.cardinality == Cardinality.SINGLE
461+
assert attr_def.type_name == AtlanCustomAttributePrimitiveType.STRING.value
462+
463+
# Test 1: Setting multi_value_select to False should NOT trigger __setattr__ logic
464+
attr_def.options.multi_value_select = False
465+
466+
assert attr_def.cardinality == Cardinality.SINGLE
467+
assert attr_def.type_name == AtlanCustomAttributePrimitiveType.STRING.value
468+
469+
# Test 2: Setting multi_value_select to True should trigger __setattr__ logic
470+
attr_def.options.multi_value_select = True
471+
472+
assert attr_def.cardinality == Cardinality.SET
473+
assert (
474+
attr_def.type_name
475+
== f"array<{AtlanCustomAttributePrimitiveType.STRING.value}>"
476+
)

0 commit comments

Comments
 (0)