|
16 | 16 | from pyatlan.model.typedef import (
|
17 | 17 | AtlanTagDef,
|
18 | 18 | AttributeDef,
|
| 19 | + Cardinality, |
19 | 20 | CustomMetadataDef,
|
20 | 21 | EntityDef,
|
21 | 22 | EnumDef,
|
@@ -443,3 +444,33 @@ def test_attribute_create_with_limited_applicability(self, client: AtlanClient):
|
443 | 444 | assert getattr(options, attribute) == json.dumps(
|
444 | 445 | list(applicable_kwargs.get(attribute)) # type: ignore[arg-type]
|
445 | 446 | )
|
| 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