@@ -183,17 +183,23 @@ def test_add_model_content():
183
183
184
184
# Basic upload of text data
185
185
mr .add_model_content (None , text_data , 'test.txt' )
186
- assert post .call_args [1 ]['files' ] == {'test.txt' : text_data }
186
+ assert post .call_args [1 ]['files' ] == {'files' : ( ' test.txt', text_data , 'multipart/form-data' ) }
187
187
188
188
# Upload of text data with content type
189
189
mr .add_model_content (None , text_data , 'test.txt' , content_type = 'application/text' )
190
- assert post .call_args [1 ]['files' ] == {'test.txt' : ('test.txt' , text_data , 'application/text' )}
190
+ assert post .call_args [1 ]['files' ] == {'files' : ('test.txt' , text_data , 'application/text' )}
191
+
192
+ # Upload of dict data without content type
193
+ import json
194
+ dict_data = {'data' : text_data }
195
+ mr .add_model_content (None , dict_data , 'dict.json' )
196
+ assert post .call_args [1 ]['files' ] == {'files' : ('dict.json' , json .dumps (dict_data ), 'multipart/form-data' )}
191
197
192
198
# Upload of binary data should include content type
193
199
binary_data = 'Test binary file contents' .encode ()
194
200
mr .add_model_content (None , binary_data , 'test.pkl' )
195
- assert post .call_args [1 ]['files' ] == {'test.pkl ' : ('test.pkl' , binary_data , 'application/octet-stream' )}
201
+ assert post .call_args [1 ]['files' ] == {'files ' : ('test.pkl' , binary_data , 'application/octet-stream' )}
196
202
197
203
# Should be able to customize content type
198
204
mr .add_model_content (None , binary_data , 'test.pkl' , content_type = 'application/image' )
199
- assert post .call_args [1 ]['files' ] == {'test.pkl ' : ('test.pkl' , binary_data , 'application/image' )}
205
+ assert post .call_args [1 ]['files' ] == {'files ' : ('test.pkl' , binary_data , 'application/image' )}
0 commit comments