def setUpClass(cls): logger.debug('STARTUP') # create xls file kvxls.writelist2xls(filenamexls, records) # create xlsx file kvxls.writelist2xls(filenamexlsx, records) # create xls file kvxls.writelist2xls(filenamexls2, records2) # create xlsx file kvxls.writelist2xls(filenamexlsx2, records2)
def test_readxlslist_findheader_f02_xlsx_unique_columns_test(self): logger.debug('STARTUP') header = list(records[0].keys()) dupkey = header[0] header.append(dupkey) aref = [] for rec in records: aref.append(list(rec.values()) + [rec[dupkey]]) kvxls.writelist2xls(filenamexlsx3, aref, optiondict={'aref_result': True}, debug=False) with self.assertRaises(Exception) as context: kvxls.readxls2list_findheader(filenamexlsx3, req_cols, optiondict={'unique_column': True}, debug=False) kvutil.remove_filename(filenamexlsx3, kvutil.functionName())
def test_readxlslist_findheader_f01_xlsx_maxrows_exceeded_in_header_search( self): logger.debug('STARTUP') # create a list of values that are used to create the xls - we have 6 blank lines at the top aref = [[''], [''], [''], [''], ['']] aref.append(list(records[0].keys())) for rec in records: aref.append(list(rec.values())) kvxls.writelist2xls(filenamexlsx3, aref, optiondict={'no_header': True}, debug=False) with self.assertRaises(Exception) as context: kvxls.readxls2list_findheader(filenamexlsx3, req_cols, optiondict={'maxrows': 2}, debug=False) kvutil.remove_filename(filenamexlsx3, kvutil.functionName())
def test_readxlslist_findheader_p11_xlsx_simple_blankReqCols_aref_result_starting_blank_lines( self): logger.debug('STARTUP') # create a list of values that are used to create the xls - we have 6 blank lines at the top aref = [[''], [''], [''], [''], ['']] aref.append(list(records[0].keys())) for rec in records: aref.append(list(rec.values())) kvxls.writelist2xls(filenamexlsx3, aref, optiondict={'aref_result': True}, debug=False) # now read in the file result = kvxls.readxls2list_findheader( filenamexlsx3, [], optiondict={'aref_result': True}, debug=False) self.assertEqual(result[0], [None, None, None, None, None, None, None]) self.assertEqual(result[6], list(records[0].values())) kvutil.remove_filename(filenamexlsx3, kvutil.functionName())
def test_writelist2xls_p01_xls_simple(self): self.assertFalse( kvxls.writelist2xls( filenamexls, records, list(records[0].keys()) ) )
def test_writelist2xls_p03_xlsx_list_no_col_aref(self): templist = [list(record.values()) for record in records] self.assertFalse( kvxls.writelist2xls( filenamexlsx, records) )
def test_writelist2xls_p02_xlsx_no_col_aref(self): self.assertFalse( kvxls.writelist2xls( filenamexlsx, records) )
def test_writelist2xls_p02_data_none(): remove_file() res = kvxls.writelist2xls(test_file, None) assert os.path.exists(test_file) remove_file()
def test_writelist2xls_p01_data_empty_list(): remove_file() res = kvxls.writelist2xls(test_file, []) assert os.path.exists(test_file) remove_file()