@@ -186,37 +186,25 @@ def test_add_model_content():
186
186
187
187
# Basic upload of text data
188
188
mr .add_model_content (None , text_data , 'test.txt' )
189
- assert list (post .call_args [1 ]['files' ].items ())[0 ][0 ] == 'files'
190
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][0 ] == 'test.txt'
191
- assert (list (post .call_args [1 ]['files' ].items ())[0 ][1 ][1 ]).read () == StringIO (text_data ).read ()
192
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][2 ] == 'multipart/form-data'
193
-
189
+ assert post .call_args [1 ]['files' ] == {'files' : ('test.txt' , StringIO (text_data ), 'multipart/form-data' )}
190
+
194
191
# Basic upload of dict data
195
192
mr .add_model_content (None , dict_data , 'dict.json' )
196
- assert list (post .call_args [1 ]['files' ].items ())[0 ][0 ] == 'files'
197
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][0 ] == 'dict.json'
198
- assert (list (post .call_args [1 ]['files' ].items ())[0 ][1 ][1 ]).read () == StringIO (json .dumps (dict_data )).read ()
199
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][2 ] == 'multipart/form-data'
193
+ assert post .call_args [1 ]['files' ] == {'files' : ('dict.json' , StringIO (json .dumps (dict_data )), 'multipart/form-data' )}
200
194
201
195
# Upload of text data with content type (set content type after string detection and conversion)
202
196
mr .add_model_content (None , text_data , 'test.txt' , content_type = 'application/text' )
203
- assert list (post .call_args [1 ]['files' ].items ())[0 ][0 ] == 'files'
204
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][0 ] == 'test.txt'
205
- assert (list (post .call_args [1 ]['files' ].items ())[0 ][1 ][1 ]).read () == StringIO (text_data ).read ()
206
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][2 ] == 'multipart/form-data'
207
-
197
+ assert post .call_args [1 ]['files' ] == {'files' : ('test.txt' , StringIO (text_data ), 'multipart/form-data' )}
198
+
208
199
# Upload of dict data with content type (set content type after dict detection and conversion)
209
200
mr .add_model_content (None , dict_data , 'dict.json' , content_type = 'application/json' )
210
- assert list (post .call_args [1 ]['files' ].items ())[0 ][0 ] == 'files'
211
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][0 ] == 'dict.json'
212
- assert (list (post .call_args [1 ]['files' ].items ())[0 ][1 ][1 ]).read () == StringIO (json .dumps (dict_data )).read ()
213
- assert list (post .call_args [1 ]['files' ].items ())[0 ][1 ][2 ] == 'multipart/form-data'
214
-
201
+ assert post .call_args [1 ]['files' ] == {'files' : ('dict.json' , StringIO (json .dumps (dict_data )), 'multipart/form-data' )}
202
+
215
203
# Upload of binary data should include content type
216
204
binary_data = 'Test binary file contents' .encode ()
217
205
mr .add_model_content (None , binary_data , 'test.pkl' )
218
- assert post .call_args [1 ]['files' ] == {'files ' : ('test.pkl' , binary_data , 'multipart/form-data' )}
206
+ assert post .call_args [1 ]['files' ] == {'test.pkl ' : ('test.pkl' , binary_data , 'multipart/form-data' )}
219
207
220
208
# Should be able to customize content type
221
209
mr .add_model_content (None , binary_data , 'test.pkl' , content_type = 'application/image' )
222
- assert post .call_args [1 ]['files' ] == {'files ' : ('test.pkl' , binary_data , 'application/image' )}
210
+ assert post .call_args [1 ]['files' ] == {'test.pkl ' : ('test.pkl' , binary_data , 'application/image' )}
0 commit comments