def testBadPath(self):
   b = False
   error = None
     importExcelToTable(self.api, "badpath.csv")
   except Exception as e:
     error = e
     b = isinstance(e, IOError) or isinstance(e, ValueError)
 def testImportTableWithMissingData(self):
   names = ['ItemRelation', 'AccountRelation', 'QuantityAmount', 
       'Amount', 'FromDate', 'ToDate']
   worksheet = 'Sheet1'
   filename = TEST_FILE2
   table = self.api.getTable()
   imported_names = importExcelToTable(self.api,
       filename, worksheet=worksheet, names=names)
   self.assertTrue(imported_names == names)
 def _testImportTable(self, names=None, worksheet=None, 
   table = self.api.getTable()
   old_table = table.copy()
   for col_pos in [ht.COLUMN1, ht.COLUMN5, None]:
     table = old_table
     self.api._table = table
     column_position = col_pos
     imported_names = importExcelToTable(self.api,
         filename, worksheet=worksheet, names=names,
     if worksheet is None:
       worksheet = 'Sheet1'
     if names is None:
       names = COLUMN_NAMES
     self.assertTrue(imported_names == names)
     indicies = range(len(names))
     pairs = zip(names, indicies)
     for name, index in pairs:
       column = table.columnFromName(name)
       if column is None:
         import pdb; pdb.set_trace()
       imported_values = column.getCells()
       expected_values = DATA[name]
       self.assertTrue(imported_values == expected_values)
       # Check the column position
       old_column = old_table.columnFromName(name)
       if old_column is not None:
         expected_index = old_table.indexFromColumn(old_column)
       elif column_position is None:
         expected_index = old_table.numColumns() + index
         ref_column = old_table.columnFromName(column_position)
         expected_index = old_table.indexFromColumn(ref_column) + index
       column_index = table.indexFromColumn(column)
       if column_index != expected_index:
         import pdb; pdb.set_trace()
       self.assertEqual(column_index, expected_index)
 def testBadColumn(self):
   with self.assertRaises(ValueError):
     importExcelToTable(self.api, TEST_FILE1, ['w'])