def test_workbook(self,c): # style copying is tested in the more complete tests # here we just check that certain atributes are set properly w = TestWriter() w.style_list = 'junk' w.wtsheet_names = 'junk' w.wtsheet_index = 'junk' w.sheet_visible = 'junk' b = make_book() w.workbook(b,'foo') compare(c.call_args_list,[((),{})]) compare(w.rdbook,b) compare(w.wtbook,C('xlwt.Workbook')) compare(w.wtname,'foo') compare(w.style_list,[]) compare(w.wtsheet_names,set()) compare(w.wtsheet_index,0) compare(w.sheet_visible,False)
def test_custom_getworkbooks(self): book = make_book((('1','2','3'),)) class TestReader(BaseReader): def get_workbooks(self): yield book,'test.xls' t = TestReader() f = Mock() t(f) compare(f.method_calls,[ ('start',(),{}), ('workbook',(C('xlutils.tests.fixtures.DummyBook'),'test.xls'),{}), ('sheet',(C('xlrd.sheet.Sheet'),'test sheet'),{}), ('row',(0,0),{}), ('cell',(0,0,0,0),{}), ('cell',(0,1,0,1),{}), ('cell',(0,2,0,2),{}), ('finish',(),{}), ]) # check we're getting the right things self.failUnless(f.method_calls[1][1][0] is book) self.failUnless(f.method_calls[2][1][0] is book.sheet_by_index(0))