Skip to content

Commit 19f3dec

Browse files
committed
Cleanup tests for mypy
Signed-off-by: Christopher Grote <[email protected]>
1 parent 73c9ed5 commit 19f3dec

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

pyatlan/cache/custom_metadata_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ def refresh_cache(cls) -> None:
6565
applicable_types: set[str] = set()
6666
if cm.attribute_defs:
6767
for attr in cm.attribute_defs:
68-
if attr.options.custom_applicable_entity_types:
68+
if attr.options and attr.options.custom_applicable_entity_types:
6969
applicable_types.update(
7070
json.loads(attr.options.custom_applicable_entity_types)
7171
)
72-
attr_id = attr.name
73-
attr_name = attr.display_name
72+
attr_id = str(attr.name)
73+
attr_name = str(attr.display_name)
7474
# Use a renamed attribute everywhere
7575
attr_renamed = to_snake_case(attr_name.replace(" ", ""))
7676
cls.map_attr_id_to_name[type_id][attr_id] = attr_renamed

pyatlan/model/typedef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def create(
427427
base_type = attribute_type.value
428428
if multi_valued:
429429
attr_def.type_name = f"array<{str(base_type)}>"
430-
attr_def.options.multi_value_select = True
430+
attr_def.options.multi_value_select = True # type: ignore
431431
else:
432432
attr_def.type_name = base_type
433433
if add_enum_values:
File renamed without changes.

tests/integration/classification_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright 2022 Atlan Pte. Ltd.
3-
import time
43
from typing import Generator, Callable
54

65
import pytest
76

87
from pyatlan.cache.classification_cache import ClassificationCache
98
from pyatlan.client.atlan import AtlanClient
109
from pyatlan.error import AtlanError
11-
from pyatlan.model.enums import AtlanClassificationColor, AtlanTypeCategory
10+
from pyatlan.model.enums import AtlanClassificationColor
1211
from pyatlan.model.typedef import ClassificationDef
1312

1413
from retry import retry

tests/integration/custom_metadata_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,19 @@ def test_cm_ipr(cm_ipr: CustomMetadataDef):
163163
assert one.display_name == CM_ATTR_IPR_MANDATORY
164164
assert one.name != CM_ATTR_IPR_MANDATORY
165165
assert one.type_name == AtlanCustomAttributePrimitiveType.BOOLEAN.value
166+
assert one.options
166167
assert not one.options.multi_value_select
167168
one = attributes[3]
168169
assert one.display_name == CM_ATTR_IPR_DATE
169170
assert one.name != CM_ATTR_IPR_DATE
170171
assert one.type_name == AtlanCustomAttributePrimitiveType.DATE.value
172+
assert one.options
171173
assert not one.options.multi_value_select
172174
one = attributes[4]
173175
assert one.display_name == CM_ATTR_IPR_URL
174176
assert one.name != CM_ATTR_IPR_URL
175177
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
178+
assert one.options
176179
assert not one.options.multi_value_select
177180

178181

@@ -237,16 +240,19 @@ def test_cm_raci(cm_raci: CustomMetadataDef):
237240
assert one.display_name == CM_ATTR_RACI_CONSULTED
238241
assert one.name != CM_ATTR_RACI_CONSULTED
239242
assert one.type_name == f"array<{AtlanCustomAttributePrimitiveType.STRING.value}>"
243+
assert one.options
240244
assert one.options.multi_value_select
241245
one = attributes[3]
242246
assert one.display_name == CM_ATTR_RACI_INFORMED
243247
assert one.name != CM_ATTR_RACI_INFORMED
244248
assert one.type_name == f"array<{AtlanCustomAttributePrimitiveType.STRING.value}>"
249+
assert one.options
245250
assert one.options.multi_value_select
246251
one = attributes[4]
247252
assert one.display_name == CM_ATTR_RACI_EXTRA
248253
assert one.name != CM_ATTR_RACI_EXTRA
249254
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
255+
assert one.options
250256
assert not one.options.multi_value_select
251257

252258

@@ -324,6 +330,7 @@ def test_cm_dq(cm_dq: CustomMetadataDef):
324330
assert one.display_name == CM_ATTR_QUALITY_TYPE
325331
assert one.name != CM_ATTR_QUALITY_TYPE
326332
assert one.type_name == CM_ENUM_DQ_TYPE
333+
assert one.options
327334
assert not one.options.multi_value_select
328335
assert one.options.primitive_type == AtlanCustomAttributePrimitiveType.OPTIONS.value
329336

@@ -552,6 +559,7 @@ def test_remove_attribute(client: AtlanClient, cm_raci: CustomMetadataDef):
552559
to_keep = existing_attr
553560
if existing_attr.display_name == CM_ATTR_RACI_EXTRA:
554561
to_keep = existing_attr.archive(by="test-automation")
562+
assert to_keep.options
555563
_removal_epoch = to_keep.options.archived_at
556564
updated_attrs.append(to_keep)
557565
existing.attribute_defs = updated_attrs
@@ -832,6 +840,7 @@ def _validate_raci_structure(
832840
assert one.display_name == CM_ATTR_RACI_RESPONSIBLE
833841
assert one.name != CM_ATTR_RACI_RESPONSIBLE
834842
assert one.type_name == f"array<{AtlanCustomAttributePrimitiveType.STRING.value}>"
843+
assert one.options
835844
assert "Database" in str(one.options.custom_applicable_entity_types)
836845
assert not one.is_archived()
837846
assert one.options.multi_value_select
@@ -840,6 +849,7 @@ def _validate_raci_structure(
840849
assert one.display_name == CM_ATTR_RACI_ACCOUNTABLE
841850
assert one.name != CM_ATTR_RACI_ACCOUNTABLE
842851
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
852+
assert one.options
843853
assert "Table" in str(one.options.custom_applicable_entity_types)
844854
assert not one.is_archived()
845855
assert not one.options.multi_value_select
@@ -848,6 +858,7 @@ def _validate_raci_structure(
848858
assert one.display_name == CM_ATTR_RACI_CONSULTED
849859
assert one.name != CM_ATTR_RACI_CONSULTED
850860
assert one.type_name == f"array<{AtlanCustomAttributePrimitiveType.STRING.value}>"
861+
assert one.options
851862
assert "Column" in str(one.options.custom_applicable_entity_types)
852863
assert not one.is_archived()
853864
assert one.options.multi_value_select
@@ -856,6 +867,7 @@ def _validate_raci_structure(
856867
assert one.display_name == CM_ATTR_RACI_INFORMED
857868
assert not one.name == CM_ATTR_RACI_INFORMED
858869
assert one.type_name == f"array<{AtlanCustomAttributePrimitiveType.STRING.value}>"
870+
assert one.options
859871
assert "MaterialisedView" in str(one.options.custom_applicable_entity_types)
860872
assert not one.is_archived()
861873
assert one.options.multi_value_select
@@ -868,6 +880,7 @@ def _validate_raci_structure(
868880
)
869881
assert one.name != CM_ATTR_RACI_EXTRA
870882
assert one.type_name == AtlanCustomAttributePrimitiveType.STRING.value
883+
assert one.options
871884
assert "AtlasGlossaryTerm" in str(one.options.custom_applicable_entity_types)
872885
assert not one.options.multi_value_select
873886
assert one.is_archived()

tests/integration/role_test.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
# Copyright 2022 Atlan Pte. Ltd.
33
from pyatlan.cache.role_cache import RoleCache
44

5+
import logging
6+
7+
LOGGER = logging.getLogger(__name__)
8+
59

610
def test_retrieve_admin():
711
admin_role_guid = RoleCache.get_id_for_name("$admin")
8-
print(admin_role_guid)
912
assert admin_role_guid
13+
LOGGER.info(f"Admin role: {admin_role_guid}")
1014

1115

1216
def test_retrieve_guest():
1317
guest_role_guid = RoleCache.get_id_for_name("$guest")
14-
print(guest_role_guid)
1518
assert guest_role_guid
19+
LOGGER.info(f"Guest role: {guest_role_guid}")
1620

1721

1822
def test_retrieve_member():
1923
member_role_guid = RoleCache.get_id_for_name("$member")
20-
print(member_role_guid)
2124
assert member_role_guid
25+
LOGGER.info(f"Member role: {member_role_guid}")

0 commit comments

Comments
 (0)