Skip to content

Commit 872e34c

Browse files
committed
Fix List Associations integ tests
1 parent c6effe5 commit 872e34c

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

tests/integ/sagemaker/lineage/test_association.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,14 @@
1515

1616
import datetime
1717

18-
import pytest
1918
from sagemaker.lineage import association
2019

2120

22-
@pytest.mark.skip(reason="Not in CMH yet")
2321
def test_create_delete(association_obj):
2422
# fixture does create and then delete, this test ensures it happens at least once
2523
assert association_obj.source_arn
2624

2725

28-
@pytest.mark.skip(reason="Not in CMH yet")
2926
def test_list(association_objs, sagemaker_session):
3027
slack = datetime.timedelta(minutes=1)
3128
now = datetime.datetime.now(datetime.timezone.utc)
@@ -35,27 +32,51 @@ def test_list(association_objs, sagemaker_session):
3532

3633
for sort_order in ["Ascending", "Descending"]:
3734
association_keys_listed = []
35+
source_arn = [assoc_obj.source_arn for assoc_obj in association_objs][0]
3836
listed = association.Association.list(
37+
source_arn=source_arn,
3938
created_after=now - slack,
4039
created_before=now + slack,
4140
sort_by="CreationTime",
4241
sort_order=sort_order,
4342
sagemaker_session=sagemaker_session,
4443
)
44+
4545
for assoc in listed:
4646
key = assoc.source_arn + ":" + assoc.destination_arn
4747
if key in association_keys:
4848
association_keys_listed.append(key)
4949

5050
if sort_order == "Descending":
5151
association_names_listed = association_keys_listed[::-1]
52-
assert association_keys == association_names_listed
52+
assert association_keys[::-1] == association_names_listed
5353
# sanity check
5454
assert association_keys_listed
5555

5656

57-
@pytest.mark.skip(reason="Not in CMH yet")
5857
def test_set_tag(association_obj, sagemaker_session):
5958
tag = {"Key": "foo", "Value": "bar"}
6059
association_obj.set_tag(tag)
61-
assert association_obj.get_tag() == tag
60+
61+
while True:
62+
actual_tags = sagemaker_session.sagemaker_client.list_tags(
63+
ResourceArn=association_obj.source_arn
64+
)["Tags"]
65+
if actual_tags:
66+
break
67+
assert len(actual_tags) == 1
68+
assert actual_tags[0] == tag
69+
70+
71+
def test_tags(association_obj, sagemaker_session):
72+
tags = [{"Key": "foo1", "Value": "bar1"}]
73+
association_obj.set_tags(tags)
74+
75+
while True:
76+
actual_tags = sagemaker_session.sagemaker_client.list_tags(
77+
ResourceArn=association_obj.source_arn
78+
)["Tags"]
79+
if actual_tags:
80+
break
81+
assert len(actual_tags) == 1
82+
assert actual_tags == tags

0 commit comments

Comments
 (0)