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