1414from __future__ import absolute_import
1515
1616import datetime
17+ import time
1718
18- import pytest
1919from sagemaker .lineage import association
2020
2121
22- @pytest .mark .skip (reason = "Not in CMH yet" )
2322def test_create_delete (association_obj ):
2423 # fixture does create and then delete, this test ensures it happens at least once
2524 assert association_obj .source_arn
2625
2726
28- @pytest .mark .skip (reason = "Not in CMH yet" )
2927def test_list (association_objs , sagemaker_session ):
3028 slack = datetime .timedelta (minutes = 1 )
3129 now = datetime .datetime .now (datetime .timezone .utc )
@@ -35,27 +33,53 @@ def test_list(association_objs, sagemaker_session):
3533
3634 for sort_order in ["Ascending" , "Descending" ]:
3735 association_keys_listed = []
36+ source_arn = [assoc_obj .source_arn for assoc_obj in association_objs ][0 ]
3837 listed = association .Association .list (
38+ source_arn = source_arn ,
3939 created_after = now - slack ,
4040 created_before = now + slack ,
4141 sort_by = "CreationTime" ,
4242 sort_order = sort_order ,
4343 sagemaker_session = sagemaker_session ,
4444 )
45+
4546 for assoc in listed :
4647 key = assoc .source_arn + ":" + assoc .destination_arn
4748 if key in association_keys :
4849 association_keys_listed .append (key )
4950
5051 if sort_order == "Descending" :
5152 association_names_listed = association_keys_listed [::- 1 ]
52- assert association_keys == association_names_listed
53+ assert association_keys [:: - 1 ] == association_names_listed
5354 # sanity check
5455 assert association_keys_listed
5556
5657
57- @pytest .mark .skip (reason = "Not in CMH yet" )
5858def test_set_tag (association_obj , sagemaker_session ):
5959 tag = {"Key" : "foo" , "Value" : "bar" }
6060 association_obj .set_tag (tag )
61- assert association_obj .get_tag () == tag
61+
62+ while True :
63+ actual_tags = sagemaker_session .sagemaker_client .list_tags (
64+ ResourceArn = association_obj .source_arn
65+ )["Tags" ]
66+ if actual_tags :
67+ break
68+ time .sleep (1 )
69+ assert len (actual_tags ) == 1
70+ assert actual_tags [0 ] == tag
71+
72+
73+ def test_tags (association_obj , sagemaker_session ):
74+ tags = [{"Key" : "foo1" , "Value" : "bar1" }]
75+ association_obj .set_tags (tags )
76+
77+ while True :
78+ actual_tags = sagemaker_session .sagemaker_client .list_tags (
79+ ResourceArn = association_obj .source_arn
80+ )["Tags" ]
81+ if actual_tags :
82+ break
83+ time .sleep (1 )
84+ assert len (actual_tags ) == 1
85+ assert actual_tags == tags
0 commit comments