Пример #1
0
 def test_string(self):
   colNameTypeIdx = SBS.ColNameTypeIdx(SBS.ColNameAndType("name", "string"), 3)
   asStr = str(colNameTypeIdx)
   self.assertEqual(asStr, "ColNameTypeIdx{ColNameAndType{name,string},3}")
   self.assertEqual(colNameTypeIdx.colName(), "name")
   self.assertEqual(colNameTypeIdx.getIdx(), 3)
   self.assertEqual(colNameTypeIdx.convertFromStr("some str"), "some str")
Пример #2
0
 def test_int(self):
   colNameTypeIdx = SBS.ColNameTypeIdx(SBS.ColNameAndType("name", "int"), 4)
   asStr = str(colNameTypeIdx)
   self.assertEqual(asStr, "ColNameTypeIdx{ColNameAndType{name,int},4}")
   self.assertEqual(colNameTypeIdx.colName(), "name")
   self.assertEqual(colNameTypeIdx.getIdx(), 4)
   self.assertEqual(colNameTypeIdx.convertFromStr("12"), 12)
Пример #3
0
 def test_float(self):
   colNameTypeIdx = SBS.ColNameTypeIdx(SBS.ColNameAndType("name", "float"), 5)
   asStr = str(colNameTypeIdx)
   self.assertEqual(asStr, "ColNameTypeIdx{ColNameAndType{name,float},5}")
   self.assertEqual(colNameTypeIdx.colName(), "name")
   self.assertEqual(colNameTypeIdx.getIdx(), 5)
   self.assertEqual(colNameTypeIdx.convertFromStr("10.5"), 10.5)
Пример #4
0
 def test_invalid_type(self):
   threwExcept = True
   try:
     colNameTypeIdx = SBS.ColNameTypeIdx(SBS.ColNameAndType("name", "invalid"), 2)
     threwExcept = False
   except Exception as errMsg:
     self.assertEqual( str(errMsg),
       "Error, type 'invalid' is not supported!  Supported types include"+\
       " ['string', 'int', 'float']!" )
   if not threwExcept:
     self.assertFalse("ERROR: Did not thown an excpetion")
Пример #5
0
def cnti(colName, colType, colIdx):
  return SBS.ColNameTypeIdx(SBS.ColNameAndType(colName, colType), colIdx)
Пример #6
0
def cnat(colName, colType="string"):
  return SBS.ColNameAndType(colName, colType)