15
15
16
16
import datetime
17
17
18
- import pytest
19
18
from sagemaker .lineage import association
20
19
21
20
22
- @pytest .mark .skip (reason = "Not in CMH yet" )
23
21
def test_create_delete (association_obj ):
24
22
# fixture does create and then delete, this test ensures it happens at least once
25
23
assert association_obj .source_arn
26
24
27
25
28
- @pytest .mark .skip (reason = "Not in CMH yet" )
29
26
def test_list (association_objs , sagemaker_session ):
30
27
slack = datetime .timedelta (minutes = 1 )
31
28
now = datetime .datetime .now (datetime .timezone .utc )
@@ -35,27 +32,51 @@ def test_list(association_objs, sagemaker_session):
35
32
36
33
for sort_order in ["Ascending" , "Descending" ]:
37
34
association_keys_listed = []
35
+ source_arn = [assoc_obj .source_arn for assoc_obj in association_objs ][0 ]
38
36
listed = association .Association .list (
37
+ source_arn = source_arn ,
39
38
created_after = now - slack ,
40
39
created_before = now + slack ,
41
40
sort_by = "CreationTime" ,
42
41
sort_order = sort_order ,
43
42
sagemaker_session = sagemaker_session ,
44
43
)
44
+
45
45
for assoc in listed :
46
46
key = assoc .source_arn + ":" + assoc .destination_arn
47
47
if key in association_keys :
48
48
association_keys_listed .append (key )
49
49
50
50
if sort_order == "Descending" :
51
51
association_names_listed = association_keys_listed [::- 1 ]
52
- assert association_keys == association_names_listed
52
+ assert association_keys [:: - 1 ] == association_names_listed
53
53
# sanity check
54
54
assert association_keys_listed
55
55
56
56
57
- @pytest .mark .skip (reason = "Not in CMH yet" )
58
57
def test_set_tag (association_obj , sagemaker_session ):
59
58
tag = {"Key" : "foo" , "Value" : "bar" }
60
59
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