@@ -41,7 +41,7 @@ def test_get_execution_role():
41
41
assert actual == 'arn:aws:iam::369233609183:role/SageMakerRole'
42
42
43
43
44
- def test_get_execution_role_works_with_service_role ():
44
+ def test_get_execution_role_works_with_servie_role ():
45
45
session = Mock ()
46
46
session .get_caller_identity_arn .return_value = \
47
47
'arn:aws:iam::369233609183:role/service-role/AmazonSageMaker-ExecutionRole-20171129T072388'
@@ -61,9 +61,7 @@ def test_get_execution_role_throws_exception_if_arn_is_not_role():
61
61
62
62
def test_get_caller_identity_arn_from_an_user (boto_session ):
63
63
sess = Session (boto_session )
64
- arn = 'arn:aws:iam::369233609183:user/mia'
65
- sess .boto_session .client ('sts' ).get_caller_identity .return_value = {'Arn' : arn }
66
- sess .boto_session .client ('iam' ).get_role .return_value = {'Role' : {'Arn' : arn }}
64
+ sess .boto_session .client ('sts' ).get_caller_identity .return_value = {'Arn' : 'arn:aws:iam::369233609183:user/mia' }
67
65
68
66
actual = sess .get_caller_identity_arn ()
69
67
assert actual == 'arn:aws:iam::369233609183:user/mia'
@@ -74,37 +72,19 @@ def test_get_caller_identity_arn_from_a_role(boto_session):
74
72
arn = 'arn:aws:sts::369233609183:assumed-role/SageMakerRole/6d009ef3-5306-49d5-8efc-78db644d8122'
75
73
sess .boto_session .client ('sts' ).get_caller_identity .return_value = {'Arn' : arn }
76
74
77
- expected_role = 'arn:aws:iam::369233609183:role/SageMakerRole'
78
- sess .boto_session .client ('iam' ).get_role .return_value = {'Role' : {'Arn' : expected_role }}
79
-
80
75
actual = sess .get_caller_identity_arn ()
81
- assert actual == expected_role
76
+ assert actual == 'arn:aws:iam::369233609183:role/SageMakerRole'
82
77
83
78
84
79
def test_get_caller_identity_arn_from_a_execution_role (boto_session ):
85
80
sess = Session (boto_session )
86
81
arn = 'arn:aws:sts::369233609183:assumed-role/AmazonSageMaker-ExecutionRole-20171129T072388/SageMaker'
87
82
sess .boto_session .client ('sts' ).get_caller_identity .return_value = {'Arn' : arn }
88
- sess .boto_session .client ('iam' ).get_role .return_value = {'Role' : {'Arn' : arn }}
89
83
90
84
actual = sess .get_caller_identity_arn ()
91
85
assert actual == 'arn:aws:iam::369233609183:role/service-role/AmazonSageMaker-ExecutionRole-20171129T072388'
92
86
93
87
94
- def test_get_caller_identity_arn_from_role_with_path (boto_session ):
95
- sess = Session (boto_session )
96
- arn_prefix = 'arn:aws:iam::369233609183:role'
97
- role_name = 'name'
98
- sess .boto_session .client ('sts' ).get_caller_identity .return_value = {'Arn' : '/' .join ([arn_prefix , role_name ])}
99
-
100
- role_path = 'path'
101
- role_with_path = '/' .join ([arn_prefix , role_path , role_name ])
102
- sess .boto_session .client ('iam' ).get_role .return_value = {'Role' : {'Arn' : role_with_path }}
103
-
104
- actual = sess .get_caller_identity_arn ()
105
- assert actual == role_with_path
106
-
107
-
108
88
def test_delete_endpoint (boto_session ):
109
89
sess = Session (boto_session )
110
90
sess .delete_endpoint ('my_endpoint' )
@@ -115,15 +95,15 @@ def test_delete_endpoint(boto_session):
115
95
def test_s3_input_all_defaults ():
116
96
prefix = 'pre'
117
97
actual = s3_input (s3_data = prefix )
118
- expected = {
119
- 'DataSource' : {
98
+ expected = \
99
+ { 'DataSource' : {
120
100
'S3DataSource' : {
121
101
'S3DataDistributionType' : 'FullyReplicated' ,
122
102
'S3DataType' : 'S3Prefix' ,
123
103
'S3Uri' : prefix
124
104
}
125
105
}
126
- }
106
+ }
127
107
assert actual .config == expected
128
108
129
109
0 commit comments