1
1
import os
2
+ import sys
3
+ from unittest import TestCase
2
4
import pyexcel as pe
3
- from pyexcel .ext import webio
4
- from pyexcel .ext import xls
5
+ import pyexcel_webio as webio
5
6
from db import Session , Base , Signature , Signature2 , engine
6
- import sys
7
7
if sys .version_info [0 ] == 2 and sys .version_info [1 ] < 7 :
8
8
from ordereddict import OrderedDict
9
9
else :
@@ -166,28 +166,28 @@ def test_wrong_file_tuple_returned(self):
166
166
myinput .get_sheet (field_name = ('xls' , None ))
167
167
168
168
169
- class TestExcelInputOnBook :
169
+ class TestExcelInputOnBook ( TestCase ) :
170
170
def setUp (self ):
171
171
self .data = [['X' , 'Y' , 'Z' ], [1 , 2 , 3 ], [4 , 5 , 6 ]]
172
172
self .data1 = [['A' , 'B' , 'C' ], [1 , 2 , 3 ], [4 , 5 , 6 ]]
173
173
mydict = OrderedDict ()
174
- mydict .update ({'sheet1 ' : self .data })
175
- mydict .update ({'sheet2 ' : self .data1 })
174
+ mydict .update ({'signature ' : self .data })
175
+ mydict .update ({'signature2 ' : self .data1 })
176
176
book = pe .Book (mydict )
177
177
self .testfile = "testfile.xls"
178
178
book .save_as (self .testfile )
179
179
180
180
def test_get_book (self ):
181
181
myinput = TestInput ()
182
182
result = myinput .get_book (file_name = self .testfile )
183
- assert result ["sheet1 " ].to_array () == self .data
184
- assert result ["sheet2 " ].to_array () == self .data1
183
+ assert result ["signature " ].to_array () == self .data
184
+ assert result ["signature2 " ].to_array () == self .data1
185
185
186
186
def test_get_book_dict (self ):
187
187
myinput = TestInput ()
188
188
result = myinput .get_book_dict (file_name = self .testfile )
189
- assert result ["sheet1 " ] == self .data
190
- assert result ["sheet2 " ] == self .data1
189
+ assert result ["signature " ] == self .data
190
+ assert result ["signature2 " ] == self .data1
191
191
192
192
def test_save_to_database (self ):
193
193
Base .metadata .drop_all (engine )
@@ -196,7 +196,7 @@ def test_save_to_database(self):
196
196
myinput = TestInput ()
197
197
myinput .save_book_to_database (file_name = self .testfile , session = self .session , tables = [Signature , Signature2 ])
198
198
array = pe .get_array (session = self .session , table = Signature )
199
- assert array == self .data
199
+ self . assertEqual ( array , self .data )
200
200
array = pe .get_array (session = self .session , table = Signature2 )
201
201
assert array == self .data1
202
202
self .session .close ()
0 commit comments