|
8 | 8 | from unittest import mock
|
9 | 9 |
|
10 | 10 | import pytest
|
11 |
| -from io import StringIO |
12 |
| -import json |
13 | 11 | from sasctl import current_session
|
14 | 12 | from sasctl.services import model_repository as mr
|
15 | 13 |
|
@@ -182,28 +180,19 @@ def test_add_model_content():
|
182 | 180 | with mock.patch('sasctl._services.model_repository.ModelRepository.get_model', return_value={'id': 123}):
|
183 | 181 | with mock.patch('sasctl._services.model_repository.ModelRepository.post') as post:
|
184 | 182 | text_data = 'Test text file contents'
|
185 |
| - dict_data = {'Test': 'dict file contents'} |
186 | 183 |
|
187 | 184 | # Basic upload of text data
|
188 | 185 | mr.add_model_content(None, text_data, 'test.txt')
|
189 |
| - assert post.call_args[1]['files'] == {'files': ('test.txt', StringIO(text_data), 'multipart/form-data')} |
190 |
| - |
191 |
| - # Basic upload of dict data |
192 |
| - mr.add_model_content(None, dict_data, 'dict.json') |
193 |
| - assert post.call_args[1]['files'] == {'files': ('dict.json', StringIO(json.dumps(dict_data)), 'multipart/form-data')} |
| 186 | + assert post.call_args[1]['files'] == {'test.txt': text_data} |
194 | 187 |
|
195 |
| - # Upload of text data with content type (set content type after string detection and conversion) |
| 188 | + # Upload of text data with content type |
196 | 189 | mr.add_model_content(None, text_data, 'test.txt', content_type='application/text')
|
197 |
| - assert post.call_args[1]['files'] == {'files': ('test.txt', StringIO(text_data), 'multipart/form-data')} |
198 |
| - |
199 |
| - # Upload of dict data with content type (set content type after dict detection and conversion) |
200 |
| - mr.add_model_content(None, dict_data, 'dict.json', content_type='application/json') |
201 |
| - assert post.call_args[1]['files'] == {'files': ('dict.json', StringIO(json.dumps(dict_data)), 'multipart/form-data')} |
202 |
| - |
| 190 | + assert post.call_args[1]['files'] == {'test.txt': ('test.txt', text_data, 'application/text')} |
| 191 | + |
203 | 192 | # Upload of binary data should include content type
|
204 | 193 | binary_data = 'Test binary file contents'.encode()
|
205 | 194 | mr.add_model_content(None, binary_data, 'test.pkl')
|
206 |
| - assert post.call_args[1]['files'] == {'test.pkl': ('test.pkl', binary_data, 'multipart/form-data')} |
| 195 | + assert post.call_args[1]['files'] == {'test.pkl': ('test.pkl', binary_data, 'application/octet-stream')} |
207 | 196 |
|
208 | 197 | # Should be able to customize content type
|
209 | 198 | mr.add_model_content(None, binary_data, 'test.pkl', content_type='application/image')
|
|
0 commit comments