File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ Change log
77Added
88********************************************************************************
99
10- #. `issue 38 <https://github.com/pyexcel/django-excel/issues/38 >`_, Support
11- unicode code as download file name
10+ #. `issue 39 <https://github.com/pyexcel/django-excel/issues/39 >`_, explicitly
11+ seeking at 0
1212
13130.0.7 - 29.06.2017
1414--------------------------------------------------------------------------------
Original file line number Diff line number Diff line change 1212import pyexcel .ext .xlsx # noqa
1313import pyexcel .ext .ods3 # noqa
1414from django_excel ._compact import urllib_quote
15+ from django_excel import ExcelInMemoryUploadedFile
1516from nose .tools import eq_
1617
1718PY2 = sys .version_info [0 ] == 2
2021else :
2122 from collections import OrderedDict
2223
24+ if PY2 :
25+ from StringIO import StringIO
26+ else :
27+ from io import StringIO
28+
29+
2330_XLSX_MIME = (
2431 "application/" +
2532 "vnd.openxmlformats-officedocument.spreadsheetml.sheet" )
@@ -279,3 +286,20 @@ class ExcelResponseUsingFileTestCase(ExcelResponseTestCase):
279286@override_settings (FILE_UPLOAD_MAX_MEMORY_SIZE = 1 )
280287class DatabaseOperationsUsingFileTestCase (DatabaseOperationsTestCase ):
281288 pass
289+
290+
291+ class TestUploadedFile (TestCase ):
292+ def test_in_memory_file (self ):
293+ test_content = 'a,b,c'
294+ strio = StringIO (test_content )
295+ strio .read ()
296+ in_memory_file = ExcelInMemoryUploadedFile (
297+ file = strio ,
298+ field_name = 'test' ,
299+ name = 'test_file' ,
300+ content_type = 'text' ,
301+ size = 3 ,
302+ charset = None
303+ )
304+ params = in_memory_file .get_params ()
305+ eq_ (params ['file_content' ], test_content )
You can’t perform that action at this time.
0 commit comments