Skip to content

Commit 7f42e7b

Browse files
committed
Revert "Update add_model_content unit tests"
This reverts commit 2a92e57.
1 parent cdbde1b commit 7f42e7b

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

tests/unit/test_model_repository.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from unittest import mock
99

1010
import pytest
11-
from io import StringIO
12-
import json
1311
from sasctl import current_session
1412
from sasctl.services import model_repository as mr
1513

@@ -182,28 +180,19 @@ def test_add_model_content():
182180
with mock.patch('sasctl._services.model_repository.ModelRepository.get_model', return_value={'id': 123}):
183181
with mock.patch('sasctl._services.model_repository.ModelRepository.post') as post:
184182
text_data = 'Test text file contents'
185-
dict_data = {'Test': 'dict file contents'}
186183

187184
# Basic upload of text data
188185
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}
194187

195-
# Upload of text data with content type (set content type after string detection and conversion)
188+
# Upload of text data with content type
196189
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+
203192
# Upload of binary data should include content type
204193
binary_data = 'Test binary file contents'.encode()
205194
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')}
207196

208197
# Should be able to customize content type
209198
mr.add_model_content(None, binary_data, 'test.pkl', content_type='application/image')

0 commit comments

Comments
 (0)