def test_book_output_stringio(self): data = {"Sheet 1": [[1, 2, 3], [4, 5, 6]]} io = pe.save_book_as(dest_file_type="xlsm", bookdict=data) b = pe.load_book_from_memory("xlsm", io.getvalue()) result = [1, 2, 3, 4, 5, 6] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual
def test_book_save_to_stringio(self): data = {"Sheet 1": [[1, 2, 3], [4, 5, 6]]} book = pe.Book(data) io = BytesIO() book.save_to_memory("xlsm", io) b = pe.load_book_from_memory("xlsm", io.getvalue()) result = [1, 2, 3, 4, 5, 6] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual
def test_book_output_stringio(self): data = {"Sheet 1": [[1, 2, 3], [4, 5, 6]]} io = BytesIO() w = pe.BookWriter(("xlsm", io)) w.write_book_from_dict(data) w.close() b = pe.load_book_from_memory("xlsm", io.getvalue()) result = [1, 2, 3, 4, 5, 6] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual
def test_book_stringio(self): csvfile = "cute.xls" create_sample_file1(csvfile) with open(csvfile, "rb") as f: content = f.read() b = pe.load_book_from_memory("xls", content) result=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual if os.path.exists(csvfile): os.unlink(csvfile)
def test_book_stringio(self): csvfile = "cute.xls" create_sample_file1(csvfile) with open(csvfile, "rb") as f: content = f.read() b = pe.load_book_from_memory("xls", content) result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual if os.path.exists(csvfile): os.unlink(csvfile)
def test_book_output_stringio(self): data = { "Sheet 1": [ [1, 2, 3], [4, 5, 6] ] } io = pe.save_book_as(dest_file_type="xlsm",bookdict=data) b = pe.load_book_from_memory("xlsm", io.getvalue()) result=[1, 2, 3, 4, 5, 6] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual
def test_book(self): for struct_type in ["book", "book_dict"]: io = BytesIO() book = pe.Book(self.content) book.save_to_memory('xls', io) io.seek(0) response = self.app.post('/exchange/%s' % struct_type, buffered=True, data={"file": (io, "test.xls")}, content_type="multipart/form-data") assert response.content_type == "application/vnd.ms-excel" book2 = pe.load_book_from_memory('xls', response.data) assert book2.to_dict() == self.content
def test_book_save_to_stringio(self): data = { "Sheet 1": [ [1, 2, 3], [4, 5, 6] ] } book = pe.Book(data) io = BytesIO() book.save_to_memory("xlsm", io) b = pe.load_book_from_memory("xlsm", io.getvalue()) result=[1, 2, 3, 4, 5, 6] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual
def test_book_output_stringio(self): data = { "Sheet 1": [ [1, 2, 3], [4, 5, 6] ] } io = BytesIO() w = pe.BookWriter(("xlsm",io)) w.write_book_from_dict(data) w.close() b = pe.load_book_from_memory("xlsm", io.getvalue()) result=[1, 2, 3, 4, 5, 6] actual = pe.utils.to_array(b[0].enumerate()) assert result == actual