Skip to content

Commit 2be3780

Browse files
authored
Merge pull request #615 from atlanhq/APP-6523
APP-6523: Added optional `description` parameters to `cm/attributedef.creator()` methods
2 parents 11a31ce + 84060dc commit 2be3780

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

pyatlan/model/typedef.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ def create(
832832
applicable_other_asset_types: Optional[OtherAssetTypes] = None,
833833
applicable_domains: Optional[Set[str]] = None,
834834
applicable_domain_types: Optional[DomainTypes] = None,
835+
description: Optional[str] = None,
835836
) -> AttributeDef:
836837
from pyatlan.utils import validate_required_fields
837838

@@ -847,7 +848,7 @@ def create(
847848
),
848849
is_new=True,
849850
cardinality=Cardinality.SINGLE,
850-
description="",
851+
description=description,
851852
name="",
852853
include_in_notification=False,
853854
is_indexable=True,
@@ -1152,7 +1153,9 @@ def with_logo_from_icon(
11521153
)
11531154

11541155
@staticmethod
1155-
def create(display_name: str) -> CustomMetadataDef:
1156+
def create(
1157+
display_name: str, description: Optional[str] = None
1158+
) -> CustomMetadataDef:
11561159
from pyatlan.utils import validate_required_fields
11571160

11581161
validate_required_fields(
@@ -1164,6 +1167,7 @@ def create(display_name: str) -> CustomMetadataDef:
11641167
category=AtlanTypeCategory.CUSTOM_METADATA,
11651168
display_name=display_name,
11661169
name=display_name,
1170+
description=description,
11671171
)
11681172

11691173

tests/integration/custom_metadata_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
"Uniqueness",
7676
]
7777
DQ_TYPE_EXTRA_LIST = ["Unknown", "Others"]
78+
CM_DESCRIPTION = "Automated testing of the Python SDK (cm)."
79+
ATTRIBUTE_DESCRIPTION = "Automated testing of the Python SDK (attribute)."
7880

7981
_removal_epoch: Optional[int]
8082

@@ -88,7 +90,7 @@ def create_custom_metadata(
8890
icon: Optional[AtlanIcon] = None,
8991
color: Optional[AtlanTagColor] = None,
9092
) -> CustomMetadataDef:
91-
cm_def = CustomMetadataDef.create(display_name=name)
93+
cm_def = CustomMetadataDef.create(display_name=name, description=CM_DESCRIPTION)
9294
cm_def.attribute_defs = attribute_defs
9395
if icon and color:
9496
cm_def.options = CustomMetadataDef.Options.with_logo_from_icon(
@@ -143,6 +145,7 @@ def cm_ipr(
143145
AttributeDef.create(
144146
display_name=CM_ATTR_IPR_LICENSE,
145147
attribute_type=AtlanCustomAttributePrimitiveType.STRING,
148+
description=ATTRIBUTE_DESCRIPTION,
146149
**limit_attribute_applicability_kwargs,
147150
),
148151
AttributeDef.create(
@@ -175,6 +178,7 @@ def test_cm_ipr(cm_ipr: CustomMetadataDef, limit_attribute_applicability_kwargs)
175178
assert cm_ipr.guid
176179
assert cm_ipr.name != cm_name
177180
assert cm_ipr.display_name == cm_name
181+
assert cm_ipr.description == CM_DESCRIPTION
178182
attributes = cm_ipr.attribute_defs
179183
assert attributes
180184
assert len(attributes) == 5
@@ -183,6 +187,7 @@ def test_cm_ipr(cm_ipr: CustomMetadataDef, limit_attribute_applicability_kwargs)
183187
assert one_with_limited.options
184188
assert one_with_limited.display_name == CM_ATTR_IPR_LICENSE
185189
assert one_with_limited.name
190+
assert one_with_limited.description == ATTRIBUTE_DESCRIPTION
186191
assert one_with_limited.name != CM_ATTR_IPR_LICENSE
187192
assert one_with_limited.type_name == AtlanCustomAttributePrimitiveType.STRING.value
188193
assert not one_with_limited.options.multi_value_select

tests/integration/test_index_search.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright 2022 Atlan Pte. Ltd.
3+
import math
34
from dataclasses import dataclass, field
45
from datetime import datetime
56
from time import sleep, time
@@ -335,8 +336,6 @@ def _assert_search_results(results, expected_sorts, size, TOTAL_ASSETS, bulk=Fal
335336

336337
@patch.object(LOGGER, "debug")
337338
def test_search_pagination(mock_logger, client: AtlanClient):
338-
size = 2
339-
340339
# Avoid testing on integration tests objects
341340
exclude_sdk_terms = [
342341
Asset.NAME.wildcard("psdk_*"),
@@ -352,13 +351,22 @@ def test_search_pagination(mock_logger, client: AtlanClient):
352351
dsl = DSL(
353352
query=query,
354353
post_filter=Term.with_type_name(value="AtlasGlossaryTerm"),
355-
size=size,
354+
size=0, # to get the total count
356355
)
356+
357357
request = IndexSearchRequest(dsl=dsl)
358358
results = client.asset.search(criteria=request)
359359
# Assigning this here to ensure the total assets
360360
# remain constant across different test cases
361361
TOTAL_ASSETS = results.count
362+
363+
# set page_size to divide into ~5 API calls
364+
size = max(1, math.ceil(TOTAL_ASSETS / 5))
365+
request.dsl.size = size
366+
367+
# Now, we can test different test scenarios for search() with the dynamic page size
368+
results = client.asset.search(criteria=request)
369+
362370
expected_sorts = [Asset.GUID.order(SortOrder.ASCENDING)]
363371
_assert_search_results(results, expected_sorts, size, TOTAL_ASSETS)
364372

@@ -385,7 +393,7 @@ def test_search_pagination(mock_logger, client: AtlanClient):
385393
FluentSearch(where_nots=exclude_sdk_terms)
386394
.where(CompoundQuery.active_assets())
387395
.where(CompoundQuery.asset_type(AtlasGlossaryTerm))
388-
.page_size(2)
396+
.page_size(size)
389397
).to_request()
390398
results = client.asset.search(criteria=request)
391399
expected_sorts = [Asset.GUID.order(SortOrder.ASCENDING)]
@@ -396,7 +404,7 @@ def test_search_pagination(mock_logger, client: AtlanClient):
396404
FluentSearch(where_nots=exclude_sdk_terms)
397405
.where(CompoundQuery.active_assets())
398406
.where(CompoundQuery.asset_type(AtlasGlossaryTerm))
399-
.page_size(2)
407+
.page_size(size)
400408
).to_request()
401409
results = client.asset.search(criteria=request, bulk=True)
402410
expected_sorts = [
@@ -413,7 +421,7 @@ def test_search_pagination(mock_logger, client: AtlanClient):
413421
FluentSearch(where_nots=exclude_sdk_terms)
414422
.where(CompoundQuery.active_assets())
415423
.where(CompoundQuery.asset_type(AtlasGlossaryTerm))
416-
.page_size(2)
424+
.page_size(size)
417425
).execute(client, bulk=True)
418426
expected_sorts = [
419427
Asset.CREATE_TIME.order(SortOrder.ASCENDING),
@@ -431,7 +439,7 @@ def test_search_pagination(mock_logger, client: AtlanClient):
431439
FluentSearch(where_nots=exclude_sdk_terms)
432440
.where(CompoundQuery.active_assets())
433441
.where(CompoundQuery.asset_type(AtlasGlossaryTerm))
434-
.page_size(2)
442+
.page_size(size)
435443
).to_request()
436444
results = client.asset.search(criteria=request)
437445
expected_sorts = [

tests/unit/test_base_vcr_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TestBaseVCRJSON(BaseVCR):
1313

1414
BASE_URL = "https://httpbin.org"
1515

16-
@pytest.fixture(scope="session")
16+
@pytest.fixture(scope="module")
1717
def vcr_config(self):
1818
"""
1919
Override the VCR configuration to use JSON serialization across the module.

0 commit comments

Comments
 (0)