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")
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)
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)
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")
def cnti(colName, colType, colIdx): return SBS.ColNameTypeIdx(SBS.ColNameAndType(colName, colType), colIdx)
def cnat(colName, colType="string"): return SBS.ColNameAndType(colName, colType)