def testSaveAndGetTable(self):
   if IGNORE_TEST:
      return
   request = self._URL2Request(self._createURL(count=1))  # a request
   self._addSessionToRequest(request)
   self.assertEqual(sv.getTable(request), None)
   table = Table("test")
   sv.saveTable(request, table)
   self.assertTrue(request.session.has_key(sv.TABLE_FILE_KEY))
   new_table = sv.getTable(request)
   self.assertEqual(new_table.getName(is_global_name=False), 
       table.getName(is_global_name=False))
Exemplo n.º 2
0
 def testSaveAndGetTable(self):
     if IGNORE_TEST:
         return
     request = self._helper_http.URL2Request(
         self._helper_http.createURL(count=1))  # a request
     self._helper_http.addSessionToRequest(request)
     self.assertEqual(sv.getTable(request), None)
     table = Table("test")
     sv.saveTable(request, table)
     self.assertTrue(request.session.has_key(sv.TABLE_FILE_KEY))
     new_table = sv.getTable(request)
     self.assertEqual(new_table.getName(is_global_name=False),
                      table.getName(is_global_name=False))
Exemplo n.º 3
0
 def _getNodes(count):
     nodes = []
     while len(nodes) < count:
         excludes = list(nodes)
         node = _getNode(self.table, "Column", excludes=excludes)
         if not Table.isNameColumn(node):
             nodes.append(node)
     return nodes
Exemplo n.º 4
0
 def setUp(self):
     cat_values = []
     for o in OTHER_NAMES:
         for s in SFX_NAMES:
             cat_values.append([o, s])
     val_dict = {
         CATEGORY_COLNM: cat_values,
         VALUES_COLNM: VALUES,
     }
     df = pd.DataFrame(val_dict)
     self.api = APIFormulas(Table("Dummy"))
     self.api.addColumnsToTableFromDataframe(df)
  def _findColumnWithType(self, table, val):
    # Inputs: table - table being analyzed
    #         val - value whose type is to be matched
    # Returns the index of the column with the specified type or None
    # Assumes that the columns are either str or a number
    def notIsStrs(vals):
      return not cell_types.isStrs(vals)

    if cell_types.isStr(val):
      func = cell_types.isStrs
    else:
      func = notIsStrs
    for column in table.getColumns():
      if Table.isNameColumn(column):
        continue
      if func(column.getCells()):
        return table.indexFromColumn(column)
Exemplo n.º 6
0
    def _findColumnWithType(self, table, val):
        """
    :param Table table:
    :param object val:
    :return Column:
    Assumes that the columns are either str or a number
    """
        def notIsStrs(vals):
            return not cell_types.isStrs(vals)

        if cell_types.isStr(val):
            func = cell_types.isStrs
        else:
            func = notIsStrs
        for column in table.getColumns():
            if Table.isNameColumn(column):
                continue
            if func(column.getCells()):
                return column