@@ -6113,3 +6113,75 @@ def test_update_inference_component(sagemaker_session):
6113
6113
)
6114
6114
6115
6115
sagemaker_session .sagemaker_client .update_inference_component .assert_called_with (** request )
6116
+
6117
+
6118
+ @patch ("os.makedirs" )
6119
+ def test_download_data_with_only_directory (makedirs , sagemaker_session ):
6120
+ sagemaker_session .s3_client = Mock ()
6121
+ sagemaker_session .s3_client .list_objects_v2 = Mock (
6122
+ return_value = {
6123
+ "Contents" : [
6124
+ {
6125
+ "Key" : "foo/bar/" ,
6126
+ "Size" : 0 ,
6127
+ }
6128
+ ]
6129
+ }
6130
+ )
6131
+ sagemaker_session .download_data (path = "." , bucket = "foo-bucket" )
6132
+
6133
+ makedirs .assert_called_with ("./foo/bar" , exist_ok = True )
6134
+ sagemaker_session .s3_client .download_file .assert_not_called ()
6135
+
6136
+
6137
+ @patch ("os.makedirs" )
6138
+ def test_download_data_with_only_file (makedirs , sagemaker_session ):
6139
+ sagemaker_session .s3_client = Mock ()
6140
+ sagemaker_session .s3_client .list_objects_v2 = Mock (
6141
+ return_value = {
6142
+ "Contents" : [
6143
+ {
6144
+ "Key" : "foo/bar/mode.tar.gz" ,
6145
+ "Size" : 100 ,
6146
+ }
6147
+ ]
6148
+ }
6149
+ )
6150
+ sagemaker_session .download_data (path = "." , bucket = "foo-bucket" )
6151
+
6152
+ makedirs .assert_called_with ("./foo/bar" , exist_ok = True )
6153
+ sagemaker_session .s3_client .download_file .assert_called_with (
6154
+ Bucket = "foo-bucket" ,
6155
+ Key = "foo/bar/mode.tar.gz" ,
6156
+ Filename = "./foo/bar/mode.tar.gz" ,
6157
+ ExtraArgs = None ,
6158
+ )
6159
+
6160
+
6161
+ @patch ("os.makedirs" )
6162
+ def test_download_data_with_file_and_directory (makedirs , sagemaker_session ):
6163
+ sagemaker_session .s3_client = Mock ()
6164
+ sagemaker_session .s3_client .list_objects_v2 = Mock (
6165
+ return_value = {
6166
+ "Contents" : [
6167
+ {
6168
+ "Key" : "foo/bar/" ,
6169
+ "Size" : 0 ,
6170
+ },
6171
+ {
6172
+ "Key" : "foo/bar/mode.tar.gz" ,
6173
+ "Size" : 100 ,
6174
+ },
6175
+ ]
6176
+ }
6177
+ )
6178
+ sagemaker_session .download_data (path = "." , bucket = "foo-bucket" )
6179
+
6180
+ makedirs .assert_called_with ("./foo/bar" , exist_ok = True )
6181
+ makedirs .assert_has_calls ([call ("./foo/bar" , exist_ok = True ), call ("./foo/bar" , exist_ok = True )])
6182
+ sagemaker_session .s3_client .download_file .assert_called_with (
6183
+ Bucket = "foo-bucket" ,
6184
+ Key = "foo/bar/mode.tar.gz" ,
6185
+ Filename = "./foo/bar/mode.tar.gz" ,
6186
+ ExtraArgs = None ,
6187
+ )
0 commit comments