def testBadPath(self):
   b = False
   error = None
   try:
     importExcelToTable(self.api, "badpath.csv")
   except Exception as e:
     error = e
     b = isinstance(e, IOError) or isinstance(e, ValueError)
   self.assertTrue(b)
示例#2
0
 def testBadPath(self):
     b = False
     error = None
     try:
         importExcelToTable(self.api, "badpath.csv")
     except Exception as e:
         error = e
         b = isinstance(e, IOError) or isinstance(e, ValueError)
     self.assertTrue(b)
 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)
示例#4
0
 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)
示例#5
0
 def _testImportTable(self,
                      names=None,
                      worksheet=None,
                      filename=TEST_FILE1):
     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,
             column_position=column_position)
         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:
             self.assertTrue(table.isColumnPresent(name))
             column = table.columnFromName(name, is_relative=True)
             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, is_relative=True)
             if old_column is not None:
                 expected_index = old_table.indexFromColumn(old_column)
             else:
                 expected_index = old_table.numColumns() + index
             column_index = table.indexFromColumn(column)
             if column_index != expected_index:
                 import pdb
                 pdb.set_trace()
             self.assertEqual(column_index, expected_index)
 def _testImportTable(self, names=None, worksheet=None, 
     filename=TEST_FILE1):
   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,
         column_position=column_position)
     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:
       self.assertTrue(table.isColumnPresent(name))
       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
       else:
         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'])
示例#8
0
 def testBadColumn(self):
     with self.assertRaises(ValueError):
         importExcelToTable(self.api, TEST_FILE1, ['w'])