@@ -162,7 +162,6 @@ def test_exchange(self):
162162 tmp_filename = "test.%s" % in_file_type
163163 sheet .save_as (tmp_filename )
164164 for file_type in FILE_TYPE_MIME_TABLE .keys ():
165- print ("Post %s -> Respond %s" % (in_file_type , file_type ))
166165 with open (tmp_filename , "rb" ) as fp :
167166 response = self .client .post (
168167 '/polls/exchange/' + file_type ,
@@ -219,6 +218,43 @@ def testBook(self):
219218 +---------------+----+-------------+-------+""" ).strip ('\n ' ) # noqa
220219 self .assertEqual (str (book ), content )
221220
221+ def testBookUsingIsave (self ):
222+ fp = open (self .testfile , "rb" )
223+ response = self .client .post ('/polls/import_using_isave/' ,
224+ data = {"file" : fp })
225+ eq_ (response .status_code , 302 )
226+ response2 = self .client .get ('/polls/export/book' )
227+ assert response2 .status_code == 200
228+ book = pe .get_book (file_type = 'xls' , file_content = response2 .content )
229+ content = dedent ("""
230+ question:
231+ +----+---------------------------+----------------------------------------------+----------+
232+ | id | pub_date | question_text | slug |
233+ +----+---------------------------+----------------------------------------------+----------+
234+ | 1 | 2015-01-28T00:00:00+00:00 | What is your favourite programming language? | language |
235+ +----+---------------------------+----------------------------------------------+----------+
236+ | 2 | 2015-01-29T00:00:00+00:00 | What is your favourite IDE? | ide |
237+ +----+---------------------------+----------------------------------------------+----------+
238+ choice:
239+ +---------------+----+-------------+-------+
240+ | choice_text | id | question_id | votes |
241+ +---------------+----+-------------+-------+
242+ | Java | 1 | 1 | 0 |
243+ +---------------+----+-------------+-------+
244+ | C++ | 2 | 1 | 0 |
245+ +---------------+----+-------------+-------+
246+ | C | 3 | 1 | 0 |
247+ +---------------+----+-------------+-------+
248+ | Eclipse | 4 | 2 | 0 |
249+ +---------------+----+-------------+-------+
250+ | Visual Studio | 5 | 2 | 0 |
251+ +---------------+----+-------------+-------+
252+ | PyCharm | 6 | 2 | 0 |
253+ +---------------+----+-------------+-------+
254+ | IntelliJ | 7 | 2 | 0 |
255+ +---------------+----+-------------+-------+""" ).strip ('\n ' ) # noqa
256+ self .assertEqual (str (book ), content )
257+
222258 def testSheet (self ):
223259 fp = open (self .testfile , "rb" )
224260 response = self .client .post ('/polls/import/' , data = {"file" : fp })
@@ -255,6 +291,25 @@ def testImportSheet(self):
255291 +----+---------------------------+----------------------------------------------+----------+""" ).strip ('\n ' ) # noqa
256292 self .assertEqual (str (sheet ), content )
257293
294+ def testImportSheetUsingISave (self ):
295+ fp = open ("sample-sheet-for-isave.xls" , "rb" )
296+ response = self .client .post ('/polls/import_sheet_using_isave/' ,
297+ data = {"file" : fp })
298+ eq_ (response .status_code , 200 )
299+ response2 = self .client .get ('/polls/export/sheet' )
300+ eq_ (response2 .status_code , 200 )
301+ sheet = pe .get_sheet (file_type = 'xls' , file_content = response2 .content )
302+ content = dedent ("""
303+ question:
304+ +----+---------------------------+----------------------------------------------+----------+
305+ | id | pub_date | question_text | slug |
306+ +----+---------------------------+----------------------------------------------+----------+
307+ | 1 | 2015-01-28T00:00:00+00:00 | What is your favourite programming language? | language |
308+ +----+---------------------------+----------------------------------------------+----------+
309+ | 2 | 2015-01-29T00:00:00+00:00 | What is your favourite IDE? | ide |
310+ +----+---------------------------+----------------------------------------------+----------+""" ).strip ('\n ' ) # noqa
311+ self .assertEqual (str (sheet ), content )
312+
258313 def testCustomExport (self ):
259314 fp = open (self .testfile , "rb" )
260315 response = self .client .post ('/polls/import/' , data = {"file" : fp })
0 commit comments